Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building for Windows fails on MacOS and Linux without additional go get #824

Closed
a-h opened this issue Sep 18, 2018 · 9 comments
Closed

Building for Windows fails on MacOS and Linux without additional go get #824

a-h opened this issue Sep 18, 2018 · 9 comments

Comments

@a-h
Copy link

a-h commented Sep 18, 2018

With the latest version of logrus, my cross-platform (Linux to Windows) build has stopped working.

Steps to reproduce:

  • Write some software which uses logrus.
  • Compile on MacOS and Linux with go get ./... then go build - works fine.
  • Try GOOS=windows go build

Fails with cannot find package "github.com/konsorten/go-windows-terminal-sequences".

Steps to workaround:

  • Run GOOS=windows go get ./... then re-run the build to get Go to include the required Windows packages.

Possible improvements:

  • Add import _ "github.com/konsorten/go-windows-terminal-sequences" in any file just to bring in the required package. (Doesn't work: build constraints exclude all Go files in /Users/adrian/go/src/github.com/konsorten/go-windows-terminal-sequences)
  • Vendor the package until Go 1.12 when modules can replace it.
@a-h
Copy link
Author

a-h commented Sep 18, 2018

This was changed in #822

@dgsb
Copy link
Collaborator

dgsb commented Sep 18, 2018

Hello @a-h , that is unfortunate that this change broke your build. But I don't think you can expect that a go get ./... can retrieve all needed dependencies for all architectures. I think you workaround is exactly what should be done. What would you like we do to fix that ?

@a-h
Copy link
Author

a-h commented Sep 18, 2018

Thanks, I just thought it worth raising an issue in case there was a simple fix, but also with a workaround for anyone else affected. I expect it’s a low number of people who would be affected.

Feel free to close.

@dgsb
Copy link
Collaborator

dgsb commented Sep 19, 2018

Hello, regarding modules we already have a module definition in logrus. We may add this dependency in it in order to be ready when modules will be widespread.

@dgsb
Copy link
Collaborator

dgsb commented Sep 19, 2018

konsorten/go-windows-terminal-sequences#1

@dgsb
Copy link
Collaborator

dgsb commented Sep 19, 2018

@a-h can you try if the build works for you in module mode ?

@a-h
Copy link
Author

a-h commented Sep 25, 2018

OK, so to test this, I did the following. Installed Go 1.11 on a Mac and started a new project in a directory under the desktop. I deleted the ~/go/pkg/mod directory to ensure that no modules were cached.

I created a go.mod file:

module github.com/a-h/logtest

require github.com/sirupsen/logrus v1.0.6

Then created a simple "Hello World" main.go:

package main

import "github.com/sirupsen/logrus"

func main() {
	logrus.Println("Hello")
}

Next, I ran GOOS=windows go build and the Go system downloaded required modules:

$ GOOS=windows go build
go: finding github.com/sirupsen/logrus v1.0.6
go: finding golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b
go: finding golang.org/x/sys v0.0.0-20180925112736-b09afc3d579e
go: downloading github.com/sirupsen/logrus v1.0.6
go: downloading golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b
go: downloading golang.org/x/sys v0.0.0-20180925112736-b09afc3d579e

GOOS=windows go build had rebuild the mod file:

module github.com/a-h/logtest

require (
	github.com/sirupsen/logrus v1.0.6
	golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b // indirect
	golang.org/x/sys v0.0.0-20180925112736-b09afc3d579e // indirect
)

I noticed that github.com/konsorten/go-windows-terminal-sequences doesn't appear in the list as an indirect reference though - maybe because it isn't part of version 1.0.6?

@dgsb
Copy link
Collaborator

dgsb commented Sep 25, 2018

@a-h indeed, this dependency was not present in v1.0.6. I've just released v1.1.0, can you try with this one ?

@a-h
Copy link
Author

a-h commented Oct 9, 2018

@dgsb yes, that works fine in module mode.

I end up with a go.mod of:

github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe h1:CHRGQ8V7OlCYtwaKPJi3iA7J+YdNKdo8j7nG5IgDhjs=
github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.1.1 h1:VzGj7lhU7KEB9e9gMpAV/v5XT2NVSvLJhJLCWbnkgXg=
github.com/sirupsen/logrus v1.1.1/go.mod h1:zrgwTnHtNr00buQ1vSptGe8m1f/BbgsPukg8qsT7A+A=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

@a-h a-h closed this as completed Oct 11, 2018
rasa added a commit to rasa/feedster that referenced this issue Dec 13, 2018
shawn1m added a commit to shawn1m/overture that referenced this issue Jan 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants