安裝go-admin


安裝過程

1.下載源碼(https://github.com/golangpkg/go-admin)后編譯

執行編譯命令

go build -ldflags "-linkmode external -extldflags -static" -o go-admin main.go

出現錯誤:
main.go:5:2: cannot find package "github.com/astaxie/beego" in any of:
D:\Go\src\github.com\astaxie\beego (from $GOROOT)
F:\xiaof\src_code\golang\src\github.com\astaxie\beego (from $GOPATH)
main.go:9:2: cannot find package "github.com/astaxie/beego/context" in any of:
D:\Go\src\github.com\astaxie\beego\context (from $GOROOT)
F:\xiaof\src_code\golang\src\github.com\astaxie\beego\context (from $GOPATH)
main.go:8:2: cannot find package "github.com/astaxie/beego/logs" in any of:
D:\Go\src\github.com\astaxie\beego\logs (from $GOROOT)
F:\xiaof\src_code\golang\src\github.com\astaxie\beego\logs (from $GOPATH)
main.go:7:2: cannot find package "github.com/astaxie/beego/orm" in any of:
D:\Go\src\github.com\astaxie\beego\orm (from $GOROOT)
F:\xiaof\src_code\golang\src\github.com\astaxie\beego\orm (from $GOPATH)
main.go:4:2: cannot find package "github.com/golangpkg/go-admin/routers" in any of:
D:\Go\src\github.com\golangpkg\go-admin\routers (from $GOROOT)
F:\xiaof\src_code\golang\src\github.com\golangpkg\go-admin\routers (from $GOPATH)
main.go:6:2: cannot find package "github.com/mattn/go-sqlite3" in any of:
D:\Go\src\github.com\mattn\go-sqlite3 (from $GOROOT)
F:\xiaof\src_code\golang\src\github.com\mattn\go-sqlite3 (from $GOPATH)

 

安裝beego包

go get github.com/astaxie/beego
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/astaxie/beego: exec: "git": executable file not found in %PATH%

 

解決辦法:

在環境變量中加入git的路徑,如PATH中新增“D:\Program Files\Git\bin“;重啟cmd窗口

 

cd $go_root_path

git clone https://github.com.cnpmjs.org/protocolbuffers/protobuf-go.git

將clone的目錄和文件放到 D:\Go\src\google.golang.org\protobuf 目錄下

 

 

 

go build -ldflags "-linkmode external -extldflags -static" -o go-admin main.go

 

D:\github\2020\go-admin>go build -ldflags "-linkmode external -extldflags -static" -o go-admin main.go

 

提示錯誤信息:
main.go:4:2: cannot find package "github.com/golangpkg/go-admin/routers" in any of:
D:\Go\src\github.com\golangpkg\go-admin\routers (from $GOROOT)
F:\xiaof\src_code\golang\src\github.com\golangpkg\go-admin\routers (from $GOPATH)
main.go:6:2: no Go files in F:\xiaof\src_code\golang\src\github.com\mattn\go-sqlite3
F:\xiaof\src_code\golang\src\github.com\astaxie\beego\orm\orm_raw.go:23:2: cannot find package "github.com/pkg/errors" in any of:
D:\Go\src\github.com\pkg\errors (from $GOROOT)
F:\xiaof\src_code\golang\src\github.com\pkg\errors (from $GOPATH)
F:\xiaof\src_code\golang\src\github.com\astaxie\beego\app.go:33:2: cannot find package "golang.org/x/crypto/acme/autocert" in any of:
D:\Go\src\golang.org\x\crypto\acme\autocert (from $GOROOT)
F:\xiaof\src_code\golang\src\golang.org\x\crypto\acme\autocert (from $GOPATH)
F:\xiaof\src_code\golang\src\github.com\prometheus\client_golang\prometheus\process_collector_windows.go:20:2: cannot find package "golang.org/x/sys/windows" in any of:
D:\Go\src\golang.org\x\sys\windows (from $GOROOT)
F:\xiaof\src_code\golang\src\golang.org\x\sys\windows (from $GOPATH)

 

 

拷貝go-admin目錄下的controllers,models,routers  到F:\xiaof\src_code\golang\src\github.com\golangpkg\go-admin

拷貝github.com\mattn\go-sqlite3 到$GOPATH的github.com\mattn\go-sqlite3中

cd $GOPATH/src/github.com/pkg ;git clone http://github.com/pkg/errors.git

cd  $GOPATH/src/golang.org/x/ ; git clone https://github.com/golang/crypto.git

 

cd $GOPATH/src/golang.org/x/; git clone https://github.com/golang/net.git;

cd $GOPATH/src/golang.org/x/; git clone https://github.com.cnpmjs.org/golang/sys.git;

cd $GOPATH/src/golang.org/x/; git clone https://github.com.cnpmjs.org/golang/text.git;

 

 

報錯:

# github.com/mattn/go-sqlite3
exec: "gcc": executable file not found in %PATH%

https://www.cnblogs.com/zsy/p/5958170.html

 

安裝tdm-gcc-9.2.0  https://g.ioiox.com/https://github.com/jmeubank/tdm-gcc/releases/download/v9.2.0-tdm64-1/tdm64-gcc-9.2.0.exe

https://jmeubank.github.io/tdm-gcc/download/

 

 設置環境變量path,添加D:\mingw64\bin到path環境變量值下

 

2.運行

將代碼拷貝至${GO_PATH}src/github目錄下

在vscode中運行程序,頁面如下:

 

3.增加調試功能

進入命令行,在go-admin目錄下運行go mod init


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM