mattermost / mattermost-plugin-starter-template

Build scripts and templates for writing Mattermost plugins.
https://developers.mattermost.com/extend/plugins/
Apache License 2.0
133 stars 121 forks source link

Missing go get on fresh install #42

Closed manland closed 5 years ago

manland commented 5 years ago

I have installed a fresh dev env (go). When i clone this repo and start make it fail with errors.

Missing dep are :

I need to go get them manually.

I see 2 options :

hanzei commented 5 years ago

Both of the packages are part of go.mod. See

What is the error that occurs?

manland commented 5 years ago
make 

main.go:9:2: cannot find package "github.com/mattermost/mattermost-server/model" in any of: /home/xxx/soft/go/src/github.com/mattermost/mattermost-server/model (from $GOROOT) /home/xxx/dev/go/src/github.com/mattermost/mattermost-server/model (from $GOPATH) 

main.go:10:2: cannot find package "github.com/pkg/errors" in any of: /home/xxx/soft/go/src/github.com/pkg/errors (from $GOROOT) /home/xxx/dev/go/src/github.com/pkg/errors (from $GOPATH) 

make: build/bin/manifest: Command not found

after go get 2 dep all is ok

hanzei commented 5 years ago

Would you please try if running export GO111MODULE=on before make fixes this issue?

ThiefMaster commented 5 years ago

I had the same issue and the export worked for me.

hanzei commented 5 years ago

@ThiefMaster @manland You should clone the repository to a directory outside of $GOPATH. This should be the "clean" way to fix this. If the repository is inside of $GOPATH, you have to run export GO111MODULE=on before the first build.

lieut-data commented 5 years ago

Go modules is still pretty new, and I know others have run into this point of confusion before. I've proposed a tweak to README.md that should clarify this: https://github.com/mattermost/mattermost-plugin-sample/pull/44.

manland commented 5 years ago

Thanks!

lieut-data commented 5 years ago

Thanks, @manland! Considering this resolved as of https://github.com/mattermost/mattermost-plugin-starter-template/pull/44.

s-trooper commented 4 years ago

i got the same error, my $GOPATH is empty and "export GO111MODULE=on" doesnt help. I have no idea of golang/enviromant. can anyone help me please?

main.go:9:2: cannot find package "github.com/mattermost/mattermost-server/v5/model" in any of:
        /usr/lib/go-1.10/src/github.com/mattermost/mattermost-server/v5/model (from $GOROOT)
        /home/xxx/go/src/github.com/mattermost/mattermost-server/v5/model (from $GOPATH)
main.go:10:2: cannot find package "github.com/pkg/errors" in any of:
        /usr/lib/go-1.10/src/github.com/pkg/errors (from $GOROOT)
        /home/xxx/go/src/github.com/pkg/errors (from $GOPATH)
main.go:11:2: cannot find package "github.com/mattermost/mattermost-server/v5/model" in any of:
        /usr/lib/go-1.10/src/github.com/mattermost/mattermost-server/v5/model (from $GOROOT)
        /home/xxx/go/src/github.com/mattermost/mattermost-server/v5/model (from $GOPATH)
main.go:12:2: cannot find package "github.com/mholt/archiver/v3" in any of:
        /usr/lib/go-1.10/src/github.com/mholt/archiver/v3 (from $GOROOT)
        /home/xxx/go/src/github.com/mholt/archiver/v3 (from $GOPATH)
main.go:13:2: cannot find package "github.com/pkg/errors" in any of:
        /usr/lib/go-1.10/src/github.com/pkg/errors (from $GOROOT)
        /home/xxx/go/src/github.com/pkg/errors (from $GOPATH)
make: build/bin/manifest: Command not found
build/setup.mk:16: *** "Cannot parse id from plugin.json".  Stop.
lieut-data commented 4 years ago

@agarciamontoro, I know you recently ran into some pain re: $GOPATH. Does this look similar to your issue? Any suggestions for @s-trooper or how we can improve things here?

s-trooper commented 4 years ago

@lieut-data i got this solved, it compiles with go1.15 but not go1.10 for me. next error that comes after can be solved with lates nodejs :)

agarciamontoro commented 4 years ago

Great that you solved this, @s-trooper! Let us know if you have any other issues.

For the record, and although I don't think this was the problem here, if anyone has problems with an empty $GOPATH, it does not hurt to do export GOPATH=$(go env GOPATH) to make sure that the OS variable is set even if GOPATH is not explicitly set (which defaults to $HOME/go)