安装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