Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

buffalo: add go.mod for use with vgo #1074

Merged
merged 4 commits into from
Jun 10, 2018
Merged

Conversation

rsc
Copy link
Contributor

@rsc rsc commented May 24, 2018

Hi Mark,

I saw on Twitter that you've been having trouble with vgo and buffalo. I'm sorry to hear that. Honestly I thought that after we resolved golang/go#24045 you were all set. For you or anyone else who's having trouble, I thought it would be helpful to send a PR showing how to add a go.mod to buffalo and then use vgo with it. This is a walkthrough more than a request that you pull this today. Feel free to close the PR if you are not ready to switch to vgo for buffalo development yet. And if you run into more trouble, please let me know. I'm always happy to help.

Thanks.
Russ


First, establish baseline buffalo behavior, by using "dep ensure" and then running tests:

$ rm -rf /tmp/gopath
$ mkdir /tmp/gopath
$ export GOPATH=/tmp/gopath
$ cd /tmp/gopath
$ go get github.com/gobuffalo/buffalo
$ cd src/github.com/gobuffalo/buffalo
$ dep ensure
$ go test ./...
ok  	github.com/gobuffalo/buffalo	0.235s
ok  	github.com/gobuffalo/buffalo/binding	0.174s
?   	github.com/gobuffalo/buffalo/buffalo	[no test files]
?   	github.com/gobuffalo/buffalo/buffalo/cmd	[no test files]
?   	github.com/gobuffalo/buffalo/buffalo/cmd/build	[no test files]
?   	github.com/gobuffalo/buffalo/buffalo/cmd/destroy	[no test files]
?   	github.com/gobuffalo/buffalo/buffalo/cmd/generate	[no test files]
?   	github.com/gobuffalo/buffalo/buffalo/cmd/updater	[no test files]
ok  	github.com/gobuffalo/buffalo/generators	0.137s
ok  	github.com/gobuffalo/buffalo/generators/action	0.163s [no tests to run]
?   	github.com/gobuffalo/buffalo/generators/assets	[no test files]
?   	github.com/gobuffalo/buffalo/generators/assets/standard	[no test files]
?   	github.com/gobuffalo/buffalo/generators/assets/webpack	[no test files]
?   	github.com/gobuffalo/buffalo/generators/docker	[no test files]
?   	github.com/gobuffalo/buffalo/generators/grift	[no test files]
?   	github.com/gobuffalo/buffalo/generators/mail	[no test files]
ok  	github.com/gobuffalo/buffalo/generators/newapp	0.152s
?   	github.com/gobuffalo/buffalo/generators/refresh	[no test files]
ok  	github.com/gobuffalo/buffalo/generators/resource	0.134s
?   	github.com/gobuffalo/buffalo/generators/soda	[no test files]
?   	github.com/gobuffalo/buffalo/grifts	[no test files]
ok  	github.com/gobuffalo/buffalo/mail	0.165s
?   	github.com/gobuffalo/buffalo/meta	[no test files]
--- FAIL: Test_PopTransaction (0.00s)
        Error Trace:    pop_transaction_test.go:94
	Error:      	Received unexpected error:
	            	sqlite3 was not compiled into the binary
        ...
--- FAIL: Test_PopTransaction_Error (0.00s)
        Error Trace:    pop_transaction_test.go:107
	Error:      	Received unexpected error:
	            	sqlite3 was not compiled into the binary
        ...
--- FAIL: Test_PopTransaction_NonSuccess (0.00s)
        Error Trace:    pop_transaction_test.go:120
	Error:      	Received unexpected error:
	            	sqlite3 was not compiled into the binary
        ...
FAIL	github.com/gobuffalo/buffalo/middleware	0.170s
ok  	github.com/gobuffalo/buffalo/middleware/basicauth	0.169s
ok  	github.com/gobuffalo/buffalo/middleware/csrf	0.167s
ok  	github.com/gobuffalo/buffalo/middleware/i18n	0.150s
?   	github.com/gobuffalo/buffalo/middleware/ssl	[no test files]
ok  	github.com/gobuffalo/buffalo/middleware/tokenauth	0.153s
?   	github.com/gobuffalo/buffalo/plugins	[no test files]
ok  	github.com/gobuffalo/buffalo/render	0.127s
ok  	github.com/gobuffalo/buffalo/worker	0.100s
$

Now use "vgo build" (or any other vgo command) to turn dep's Gopkg.lock into a populated go.mod file:

$ vgo build
vgo: finding gopkg.in/yaml.v2 v2.2.1
vgo: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
vgo: finding gopkg.in/mail.v2 v2.0.0-20180301192024-63235f23494b
vgo: finding gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc
vgo: finding golang.org/x/sys v0.0.0-20180524104336-56ad15cc2170
vgo: finding golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
vgo: finding golang.org/x/net v0.0.0-20180522190444-9ef9f5bb98a1
...
$ cat go.mod
module github.com/gobuffalo/buffalo

require (
	dmitri.shuralyov.com/text/kebabcase v0.0.0-20180217051803-40e40b42552a
	github.com/ajg/form v0.0.0-20160802194845-cc2954064ec9
	github.com/dgrijalva/jwt-go v0.0.0-20180308231308-06ea1031745c
	github.com/dustin/go-humanize v0.0.0-20180421182945-02af3965c54e
	github.com/fatih/color v1.7.0
	github.com/fsnotify/fsnotify v1.4.7
	github.com/gobuffalo/packr v1.11.0
	...
)
$

Run tests to see that baseline behavior hasn't changed:

$ vgo test ./...
ok  	github.com/gobuffalo/buffalo	0.251s
ok  	github.com/gobuffalo/buffalo/binding	0.180s
?   	github.com/gobuffalo/buffalo/buffalo	[no test files]
?   	github.com/gobuffalo/buffalo/buffalo/cmd	[no test files]
?   	github.com/gobuffalo/buffalo/buffalo/cmd/build	[no test files]
?   	github.com/gobuffalo/buffalo/buffalo/cmd/destroy	[no test files]
?   	github.com/gobuffalo/buffalo/buffalo/cmd/generate	[no test files]
?   	github.com/gobuffalo/buffalo/buffalo/cmd/updater	[no test files]
ok  	github.com/gobuffalo/buffalo/generators	0.140s
ok  	github.com/gobuffalo/buffalo/generators/action	0.123s [no tests to run]
?   	github.com/gobuffalo/buffalo/generators/assets	[no test files]
?   	github.com/gobuffalo/buffalo/generators/assets/standard	[no test files]
?   	github.com/gobuffalo/buffalo/generators/assets/webpack	[no test files]
?   	github.com/gobuffalo/buffalo/generators/docker	[no test files]
?   	github.com/gobuffalo/buffalo/generators/grift	[no test files]
?   	github.com/gobuffalo/buffalo/generators/mail	[no test files]
ok  	github.com/gobuffalo/buffalo/generators/newapp	0.149s
?   	github.com/gobuffalo/buffalo/generators/refresh	[no test files]
ok  	github.com/gobuffalo/buffalo/generators/resource	0.135s
?   	github.com/gobuffalo/buffalo/generators/soda	[no test files]
?   	github.com/gobuffalo/buffalo/grifts	[no test files]
ok  	github.com/gobuffalo/buffalo/mail	0.157s
?   	github.com/gobuffalo/buffalo/meta	[no test files]
--- FAIL: Test_PopTransaction (0.00s)
        Error Trace:    pop_transaction_test.go:94
	Error:      	Received unexpected error:
	            	sqlite3 was not compiled into the binary
        ...
--- FAIL: Test_PopTransaction_Error (0.00s)
        Error Trace:    pop_transaction_test.go:107
	Error:      	Received unexpected error:
	            	sqlite3 was not compiled into the binary
        ...
--- FAIL: Test_PopTransaction_NonSuccess (0.00s)
        Error Trace:    pop_transaction_test.go:120
	Error:      	Received unexpected error:
	            	sqlite3 was not compiled into the binary
        ...
FAIL	github.com/gobuffalo/buffalo/middleware	0.159s
ok  	github.com/gobuffalo/buffalo/middleware/basicauth	0.157s
ok  	github.com/gobuffalo/buffalo/middleware/csrf	0.166s
ok  	github.com/gobuffalo/buffalo/middleware/i18n	0.171s
?   	github.com/gobuffalo/buffalo/middleware/ssl	[no test files]
ok  	github.com/gobuffalo/buffalo/middleware/tokenauth	0.173s
?   	github.com/gobuffalo/buffalo/plugins	[no test files]
ok  	github.com/gobuffalo/buffalo/render	0.128s
ok  	github.com/gobuffalo/buffalo/worker	0.079s
$

Finally, git add go.mod and git commit.

First, establish baseline buffalo behavior, by using
"dep ensure" and then running tests:

	$ rm -rf /tmp/gopath
	$ mkdir /tmp/gopath
	$ export GOPATH=/tmp/gopath
	$ cd /tmp/gopath
	$ go get github.com/gobuffalo/buffalo
	$ cd src/github.com/gobuffalo/buffalo
	$ dep ensure
	$ go test ./...
	ok  	github.com/gobuffalo/buffalo	0.235s
	ok  	github.com/gobuffalo/buffalo/binding	0.174s
	?   	github.com/gobuffalo/buffalo/buffalo	[no test files]
	?   	github.com/gobuffalo/buffalo/buffalo/cmd	[no test files]
	?   	github.com/gobuffalo/buffalo/buffalo/cmd/build	[no test files]
	?   	github.com/gobuffalo/buffalo/buffalo/cmd/destroy	[no test files]
	?   	github.com/gobuffalo/buffalo/buffalo/cmd/generate	[no test files]
	?   	github.com/gobuffalo/buffalo/buffalo/cmd/updater	[no test files]
	ok  	github.com/gobuffalo/buffalo/generators	0.137s
	ok  	github.com/gobuffalo/buffalo/generators/action	0.163s [no tests to run]
	?   	github.com/gobuffalo/buffalo/generators/assets	[no test files]
	?   	github.com/gobuffalo/buffalo/generators/assets/standard	[no test files]
	?   	github.com/gobuffalo/buffalo/generators/assets/webpack	[no test files]
	?   	github.com/gobuffalo/buffalo/generators/docker	[no test files]
	?   	github.com/gobuffalo/buffalo/generators/grift	[no test files]
	?   	github.com/gobuffalo/buffalo/generators/mail	[no test files]
	ok  	github.com/gobuffalo/buffalo/generators/newapp	0.152s
	?   	github.com/gobuffalo/buffalo/generators/refresh	[no test files]
	ok  	github.com/gobuffalo/buffalo/generators/resource	0.134s
	?   	github.com/gobuffalo/buffalo/generators/soda	[no test files]
	?   	github.com/gobuffalo/buffalo/grifts	[no test files]
	ok  	github.com/gobuffalo/buffalo/mail	0.165s
	?   	github.com/gobuffalo/buffalo/meta	[no test files]
	--- FAIL: Test_PopTransaction (0.00s)
	        Error Trace:    pop_transaction_test.go:94
		Error:      	Received unexpected error:
		            	sqlite3 was not compiled into the binary
	        ...
	--- FAIL: Test_PopTransaction_Error (0.00s)
	        Error Trace:    pop_transaction_test.go:107
		Error:      	Received unexpected error:
		            	sqlite3 was not compiled into the binary
	        ...
	--- FAIL: Test_PopTransaction_NonSuccess (0.00s)
	        Error Trace:    pop_transaction_test.go:120
		Error:      	Received unexpected error:
		            	sqlite3 was not compiled into the binary
	        ...
	FAIL	github.com/gobuffalo/buffalo/middleware	0.170s
	ok  	github.com/gobuffalo/buffalo/middleware/basicauth	0.169s
	ok  	github.com/gobuffalo/buffalo/middleware/csrf	0.167s
	ok  	github.com/gobuffalo/buffalo/middleware/i18n	0.150s
	?   	github.com/gobuffalo/buffalo/middleware/ssl	[no test files]
	ok  	github.com/gobuffalo/buffalo/middleware/tokenauth	0.153s
	?   	github.com/gobuffalo/buffalo/plugins	[no test files]
	ok  	github.com/gobuffalo/buffalo/render	0.127s
	ok  	github.com/gobuffalo/buffalo/worker	0.100s
	$

Now use "vgo build" (or any other vgo command) to turn dep's Gopkg.lock
into a populated go.mod file:

	$ vgo build
	vgo: finding gopkg.in/yaml.v2 v2.2.1
	vgo: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
	vgo: finding gopkg.in/mail.v2 v2.0.0-20180301192024-63235f23494b
	vgo: finding gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc
	vgo: finding golang.org/x/sys v0.0.0-20180524104336-56ad15cc2170
	vgo: finding golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
	vgo: finding golang.org/x/net v0.0.0-20180522190444-9ef9f5bb98a1
	...
	$ cat go.mod
	module github.com/gobuffalo/buffalo

	require (
		dmitri.shuralyov.com/text/kebabcase v0.0.0-20180217051803-40e40b42552a
		github.com/ajg/form v0.0.0-20160802194845-cc2954064ec9
		github.com/dgrijalva/jwt-go v0.0.0-20180308231308-06ea1031745c
		github.com/dustin/go-humanize v0.0.0-20180421182945-02af3965c54e
		github.com/fatih/color v1.7.0
		github.com/fsnotify/fsnotify v1.4.7
		github.com/gobuffalo/packr v1.11.0
		...
	)
	$

Run tests to see that baseline behavior hasn't changed:

	$ vgo test ./...
	ok  	github.com/gobuffalo/buffalo	0.251s
	ok  	github.com/gobuffalo/buffalo/binding	0.180s
	?   	github.com/gobuffalo/buffalo/buffalo	[no test files]
	?   	github.com/gobuffalo/buffalo/buffalo/cmd	[no test files]
	?   	github.com/gobuffalo/buffalo/buffalo/cmd/build	[no test files]
	?   	github.com/gobuffalo/buffalo/buffalo/cmd/destroy	[no test files]
	?   	github.com/gobuffalo/buffalo/buffalo/cmd/generate	[no test files]
	?   	github.com/gobuffalo/buffalo/buffalo/cmd/updater	[no test files]
	ok  	github.com/gobuffalo/buffalo/generators	0.140s
	ok  	github.com/gobuffalo/buffalo/generators/action	0.123s [no tests to run]
	?   	github.com/gobuffalo/buffalo/generators/assets	[no test files]
	?   	github.com/gobuffalo/buffalo/generators/assets/standard	[no test files]
	?   	github.com/gobuffalo/buffalo/generators/assets/webpack	[no test files]
	?   	github.com/gobuffalo/buffalo/generators/docker	[no test files]
	?   	github.com/gobuffalo/buffalo/generators/grift	[no test files]
	?   	github.com/gobuffalo/buffalo/generators/mail	[no test files]
	ok  	github.com/gobuffalo/buffalo/generators/newapp	0.149s
	?   	github.com/gobuffalo/buffalo/generators/refresh	[no test files]
	ok  	github.com/gobuffalo/buffalo/generators/resource	0.135s
	?   	github.com/gobuffalo/buffalo/generators/soda	[no test files]
	?   	github.com/gobuffalo/buffalo/grifts	[no test files]
	ok  	github.com/gobuffalo/buffalo/mail	0.157s
	?   	github.com/gobuffalo/buffalo/meta	[no test files]
	--- FAIL: Test_PopTransaction (0.00s)
	        Error Trace:    pop_transaction_test.go:94
		Error:      	Received unexpected error:
		            	sqlite3 was not compiled into the binary
	        ...
	--- FAIL: Test_PopTransaction_Error (0.00s)
	        Error Trace:    pop_transaction_test.go:107
		Error:      	Received unexpected error:
		            	sqlite3 was not compiled into the binary
	        ...
	--- FAIL: Test_PopTransaction_NonSuccess (0.00s)
	        Error Trace:    pop_transaction_test.go:120
		Error:      	Received unexpected error:
		            	sqlite3 was not compiled into the binary
	        ...
	FAIL	github.com/gobuffalo/buffalo/middleware	0.159s
	ok  	github.com/gobuffalo/buffalo/middleware/basicauth	0.157s
	ok  	github.com/gobuffalo/buffalo/middleware/csrf	0.166s
	ok  	github.com/gobuffalo/buffalo/middleware/i18n	0.171s
	?   	github.com/gobuffalo/buffalo/middleware/ssl	[no test files]
	ok  	github.com/gobuffalo/buffalo/middleware/tokenauth	0.173s
	?   	github.com/gobuffalo/buffalo/plugins	[no test files]
	ok  	github.com/gobuffalo/buffalo/render	0.128s
	ok  	github.com/gobuffalo/buffalo/worker	0.079s
	$

Finally, git add go.mod and git commit.
@swinSpo
Copy link

swinSpo commented May 25, 2018

So Mark has issues using and trying out vgo, and your solution is to ditch vgo and use the versions provided by dep?

This is honestly disappointing. What are we supposed to take away from this?

I have tried using vgo to build Buffalo and it does not work, just like mark said in his tweet.
Could you address the actual issue and use vgo for this please?

@rsc
Copy link
Contributor Author

rsc commented May 25, 2018

@swinSpo I think you should take from it that vgo is committed to continuity and graceful transition from other version-helping tools and can pick up your dep (glide, govendor, etc) config wherever you are and let you move forward from there as you deem appropriate. In any event, there are plenty of other forums besides the buffalo issue tracker if you want to criticize vgo itself. For example, https://www.reddit.com/r/golang/comments/8lzt8y.

@markbates
Copy link
Member

markbates commented May 25, 2018 via email

@swinSpo
Copy link

swinSpo commented May 25, 2018

@rsc My understand of the issue was that resolving the versions using vgo did not work, so showing us how to resolve the versions using dep is not addressing the issue.

@markbates Wasn't this the issue you were facing? Resolving the versions using vgo?
Can you build buffalo, using the VGO version resolver?

@markbates markbates added this to the 0.11.2 milestone May 30, 2018
@markbates markbates changed the base branch from master to development May 30, 2018 12:59
@markbates markbates merged commit e200f1f into gobuffalo:development Jun 10, 2018
@arschles arschles mentioned this pull request Jun 13, 2018
@markbates
Copy link
Member

markbates commented Jul 24, 2018

I'm re-opening this issue as with 1.11-tip, Go modules still do not work correctly with Buffalo.

The behavior described by @rsc does not work with go 1.11. This was tested in the development branch.

$ dep ensure
$ set -x GO111MODULE on
$ rm go.mod
$ go build -v . 
go: creating new go.mod: module github.com/gobuffalo/buffalo
go: copying requirements from Gopkg.lock
Fetching https://golang.org/x/crypto?go-get=1
Fetching https://gopkg.in/yaml.v2?go-get=1
Fetching https://golang.org/x/sync?go-get=1
Fetching https://golang.org/x/sys?go-get=1
Parsing meta tags from https://gopkg.in/yaml.v2?go-get=1 (status code 200)
get "gopkg.in/yaml.v2": found meta tag get.metaImport{Prefix:"gopkg.in/yaml.v2", VCS:"git", RepoRoot:"https://gopkg.in/yaml.v2"} at https://gopkg.in/yaml.v2?go-get=1
Fetching https://golang.org/x/net?go-get=1
Fetching https://google.golang.org/appengine?go-get=1
Parsing meta tags from https://golang.org/x/net?go-get=1 (status code 200)
get "golang.org/x/net": found meta tag get.metaImport{Prefix:"golang.org/x/net", VCS:"git", RepoRoot:"https://go.googlesource.com/net"} at https://golang.org/x/net?go-get=1
Parsing meta tags from https://google.golang.org/appengine?go-get=1 (status code 200)
get "google.golang.org/appengine": found meta tag get.metaImport{Prefix:"google.golang.org/appengine", VCS:"git", RepoRoot:"https://github.com/golang/appengine"} at https://google.golang.org/appengine?go-get=1
Fetching https://golang.org/x/text?go-get=1
Fetching https://gopkg.in/mail.v2?go-get=1
Parsing meta tags from https://golang.org/x/sys?go-get=1 (status code 200)
get "golang.org/x/sys": found meta tag get.metaImport{Prefix:"golang.org/x/sys", VCS:"git", RepoRoot:"https://go.googlesource.com/sys"} at https://golang.org/x/sys?go-get=1
Parsing meta tags from https://gopkg.in/mail.v2?go-get=1 (status code 200)
get "gopkg.in/mail.v2": found meta tag get.metaImport{Prefix:"gopkg.in/mail.v2", VCS:"git", RepoRoot:"https://gopkg.in/mail.v2"} at https://gopkg.in/mail.v2?go-get=1
Fetching https://gopkg.in/alexcesaro/quotedprintable.v3?go-get=1
Parsing meta tags from https://gopkg.in/alexcesaro/quotedprintable.v3?go-get=1 (status code 200)
get "gopkg.in/alexcesaro/quotedprintable.v3": found meta tag get.metaImport{Prefix:"gopkg.in/alexcesaro/quotedprintable.v3", VCS:"git", RepoRoot:"https://gopkg.in/alexcesaro/quotedprintable.v3"} at https://gopkg.in/alexcesaro/quotedprintable.v3?go-get=1
Parsing meta tags from https://golang.org/x/text?go-get=1 (status code 200)
get "golang.org/x/text": found meta tag get.metaImport{Prefix:"golang.org/x/text", VCS:"git", RepoRoot:"https://go.googlesource.com/text"} at https://golang.org/x/text?go-get=1
Parsing meta tags from https://golang.org/x/sync?go-get=1 (status code 200)
get "golang.org/x/sync": found meta tag get.metaImport{Prefix:"golang.org/x/sync", VCS:"git", RepoRoot:"https://go.googlesource.com/sync"} at https://golang.org/x/sync?go-get=1
Fetching https://dmitri.shuralyov.com/text/kebabcase?go-get=1
Parsing meta tags from https://dmitri.shuralyov.com/text/kebabcase?go-get=1 (status code 200)
get "dmitri.shuralyov.com/text/kebabcase": found meta tag get.metaImport{Prefix:"dmitri.shuralyov.com/text/kebabcase", VCS:"git", RepoRoot:"https://dmitri.shuralyov.com/text/kebabcase"} at https://dmitri.shuralyov.com/text/kebabcase?go-get=1
Parsing meta tags from https://golang.org/x/crypto?go-get=1 (status code 200)
get "golang.org/x/crypto": found meta tag get.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"} at https://golang.org/x/crypto?go-get=1
go: finding github.com/gobuffalo/plush v0.0.0-20180724100351-726a3d7f08d2
github.com/gobuffalo/fizz
# github.com/gobuffalo/fizz
../../../mod/github.com/gobuffalo/fizz@v1.0.2/bubbler.go:48:9: undefined: plush.RunScript

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants