在 Go 中通过指令编译并安装包到本地:go install uc, 这会将 uc.a 复制到 E:\wwwroot\go\pkg\windows_amd64 下面

1、参考网址:https://www.shuijingwanwq.com/2020/07/02/4288/ 。之前仅能够将代码文件放于:C:\Users\Administrator\go\src 下面才行。放于:E:\wwwroot\go\src 则报错。

2、编辑环境变量 – Administrator 的用户变量 – GOPATH,其原值为:C:\Users\Administrator\go,新建:E:\wwwroot\go。其新值为:C:\Users\Administrator\go;E:\wwwroot\go。如图1

图1

3、参考网址:https://github.com/unknwon/the-way-to-go_ZH_CN/blob/master/eBook/09.8.md 。通过指令编译并安装包到本地:go install uc, 这会将 uc.a 复制到 E:\wwwroot\go\pkg\windows_amd64 下面。如图2

图2

PS E:\wwwroot\go\src> cd uc
PS E:\wwwroot\go\src\uc> ls


    目录: E:\wwwroot\go\src\uc


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       2020/07/30     19:01             96 Makefile
-a----       2020/07/27     20:25            100 uc.go
-a----       2020/07/27     20:30            380 uc_test.go


PS E:\wwwroot\go\src\uc> cd ..
PS E:\wwwroot\go\src> go install uc
PS E:\wwwroot\go\src> cd ..
PS E:\wwwroot\go> cd .\pkg\
PS E:\wwwroot\go\pkg> ls


    目录: E:\wwwroot\go\pkg


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       2020/08/04     19:25                windows_amd64


PS E:\wwwroot\go\pkg> cd .\windows_amd64\
PS E:\wwwroot\go\pkg\windows_amd64> ls


    目录: E:\wwwroot\go\pkg\windows_amd64


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       2020/08/04     19:36           1568 uc.a

 

永夜