go build fail
lovecn opened this issue · 4 comments
lovecn commented
[root@VM_0_14_centos poster-generater]# go build
main.go:6:2: cannot find package "github.com/fogleman/gg" in any of:
/usr/lib/golang/src/github.com/fogleman/gg (from $GOROOT)
/root/go/src/github.com/fogleman/gg (from $GOPATH)
main.go:7:2: cannot find package "github.com/gin-gonic/gin" in any of:
/usr/lib/golang/src/github.com/gin-gonic/gin (from $GOROOT)
/root/go/src/github.com/gin-gonic/gin (from $GOPATH)
main.go:8:2: cannot find package "github.com/nfnt/resize" in any of:
/usr/lib/golang/src/github.com/nfnt/resize (from $GOROOT)
/root/go/src/github.com/nfnt/resize (from $GOPATH)
main.go:9:2: cannot find package "github.com/qbhy/go-utils" in any of:
/usr/lib/golang/src/github.com/qbhy/go-utils (from $GOROOT)
/root/go/src/github.com/qbhy/go-utils (from $GOPATH)
main.go:10:2: cannot find package "github.com/qbhy/poster-generater/config" in any of:
/usr/lib/golang/src/github.com/qbhy/poster-generater/config (from $GOROOT)
/root/go/src/github.com/qbhy/poster-generater/config (from $GOPATH)
[root@VM_0_14_centos poster-generater]# go version
go version go1.9.4 linux/amd64
qbhy commented
你没有把当前目录放到 GOPATH 下
lovecn commented
@qbhy 当前目录放到 GOPATH 下 还是有错,能做成直接go get吗
[root@VM_0_14_centos poster-generater]# go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GORACE=""
GOROOT="/usr/lib/golang"
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build330423482=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
[root@VM_0_14_centos poster-generater]# pwd
/root/go/src/poster-generater
[root@VM_0_14_centos poster-generater]# go build
main.go:10:2: cannot find package "github.com/qbhy/poster-generater/config" in any of:
/root/go/src/poster-generater/vendor/github.com/qbhy/poster-generater/config (vendor tree)
/usr/lib/golang/src/github.com/qbhy/poster-generater/config (from $GOROOT)
/root/go/src/github.com/qbhy/poster-generater/config (from $GOPATH)
lovecn commented
把 qbhy/poster-generater/config 复制到/root/go/src/poster-generater/vendor/github.com下才好了,还以为运行的是 ./poster-generater {port:7877} ,博主这文档得改下
[root@VM_0_14_centos poster-generater]# ./poster-generater 7877
[GIN-debug] [WARNING] Now Gin requires Go 1.6 or later and Go 1.7 will be required soon.
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)
[GIN-debug] GET /assets/*filepath --> poster-generater/vendor/github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (3 handlers)
[GIN-debug] HEAD /assets/*filepath --> poster-generater/vendor/github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (3 handlers)
[GIN-debug] POST /poster --> main.main.func1 (3 handlers)
[GIN-debug] Listening and serving HTTP on :7877
[GIN] 2018/12/19 - 11:48:03 | 404 | 1.05µs | 218.30.113.34 | GET /
[GIN] 2018/12/19 - 11:48:03 | 404 | 1.597µs | 218.30.113.34 | GET /favicon.ico
[GIN] 2018/12/19 - 11:48:06 | 404 | 1.504µs | 218.30.113.34 | GET /
qbhy commented
好的。