没有不值得去解决的问题,也没有不值得去学习的技术!

Error When Installing the API With go install google.golang.org/api/urlshortener/v1: Can’t Load Package

Run the following command in the terminal to install the API: go install google.golang.org/api/urlshortener/v1. Error: can't load package: package google.golang.org/api/urlshortener/v1.

1. Run the following command in the terminal to install the API: go install google.golang.org/api/urlshortener/v1. Error: can’t load package: package google.golang.org/api/urlshortener/v1. See Figure 1.

Run the following command in the terminal to install the API: go install google.golang.org/api/urlshortener/v1. Error: can't load package: package google.golang.org/api/urlshortener/v1.
Figure 1
Plaintext
PS E:\wwwroot\go\src\uc> go install google.golang.org/api/urlshortener/v1
can't load package: package google.golang.org/api/urlshortener/v1: cannot find package "google.golang.org/api/urlshorten
er/v1" in any of:
        c:\go\src\google.golang.org\api\urlshortener\v1 (from $GOROOT)
        C:\Users\Administrator\go\src\google.golang.org\api\urlshortener\v1 (from $GOPATH)
        E:\wwwroot\go\src\google.golang.org\api\urlshortener\v1

2. Reference: https://github.com/googleapis/google-api-go-client/blob/master/GettingStarted.md . Run the following command in the terminal to install the API: go get -u google.golang.org/api/urlshortener/v1. Error: package google.golang.org/api/urlshortener/v1: unrecognized import path “google.golang.org/api/urlshortener/v1”. See Figure 2.

Reference: https://github.com/googleapis/google-api-go-client/blob/master/GettingStarted.md . Run the following command in the terminal to install the API: go get -u google.golang.org/api/urlshortener/v1. Error: package google.golang.org/api/urlshortener/v1: unrecognized import path "google.golang.org/api/urlshortener/v1".
Figure 2
Plaintext
PS E:\wwwroot\go\src\uc> go get -u google.golang.org/api/urlshortener/v1
package google.golang.org/api/urlshortener/v1: unrecognized import path "google.golang.org/api/urlshortener/v1" (https f
etch: Get https://google.golang.org/api/urlshortener/v1?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection att
empt failed because the connected party did not properly respond after a period of time, or established connection faile
d because connected host has failed to respond.)

3. Reference: Run the following command in the terminal to install the API: go get -u google.golang.org/api/urlshortener/v1. See Figure 3.

Reference: https://www.shuijingwanwq.com/2019/12/28/3784/ . Run the following command in the terminal to install the API: go get -u google.golang.org/api/urlshortener/v1.
Figure 3
Plaintext
C:\Users\Administrator>set HTTP_PROXY=http://127.0.0.1:50999

C:\Users\Administrator>set HTTPS_PROXY=http://127.0.0.1:50999

C:\Users\Administrator>ping golang.org

Pinging golang-consa.l.google.com [216.239.37.1] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 216.239.37.1:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

C:\Users\Administrator>curl -vv http://www.google.com
* Rebuilt URL to: http://www.google.com/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 50999 (#0)
> GET http://www.google.com/ HTTP/1.1
> Host: www.google.com
> User-Agent: curl/7.55.1
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 301 Moved Permanently
< Connection: close
< Cache-Control: max-age:86400
< Date: Thursday, 27-Aug-20 19:44:50 CST
< Expires: Fri, 28 Aug 2020 19:44:50 GMT
< Keep-Alive: timeout=58
< Location: https://www.google.com/
< Content-Length: 0
<
* Closing connection 0

C:\Users\Administrator> go get -u google.golang.org/api/urlshortener/v1
# cd .; git clone -- https://github.com/grpc/grpc-go C:\Users\Administrator\go\src\google.golang.org\grpc
Cloning into 'C:\Users\Administrator\go\src\google.golang.org\grpc'...
fatal: the remote end hung up unexpectedly
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
package google.golang.org/grpc: exit status 128
package google.golang.org/grpc/codes: cannot find package "google.golang.org/grpc/codes" in any of:
        c:\go\src\google.golang.org\grpc\codes (from $GOROOT)
        C:\Users\Administrator\go\src\google.golang.org\grpc\codes (from $GOPATH)
        E:\wwwroot\go\src\google.golang.org\grpc\codes
package google.golang.org/grpc/status: cannot find package "google.golang.org/grpc/status" in any of:
        c:\go\src\google.golang.org\grpc\status (from $GOROOT)
        C:\Users\Administrator\go\src\google.golang.org\grpc\status (from $GOPATH)
        E:\wwwroot\go\src\google.golang.org\grpc\status

C:\Users\Administrator> go get -u google.golang.org/api/urlshortener/v1

C:\Users\Administrator>


4. Check the directory: C:\Users\Administrator\go\src\google.golang.org\api. The directory urlshortener already exists, indicating the API was installed successfully. See Figure 4.

Check the directory: C:\Users\Administrator\go\src\google.golang.org\api. The directory urlshortener already exists, indicating the API was installed successfully.
Figure 4

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系