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

Replace go-bindata with //go:embed from Go 1.16 #392

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/.vagrant
/.build
/ui/.build
/node_modules
.DS_Store
*.exe
Expand Down
13 changes: 5 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,21 @@ endif

ALL: $(CMDS)

ui: ui/bindata.go
ui: ui/.build/ui

node_modules:
npm install

$(GOPATH)/bin/houndd: ui/bindata.go $(SRCS)
$(GOPATH)/bin/houndd: ui/.build/ui $(SRCS)
go install github.com/hound-search/hound/cmds/houndd

$(GOPATH)/bin/hound: ui/bindata.go $(SRCS)
go install github.com/hound-search/hound/cmds/hound

.build/bin/go-bindata:
GOPATH=`pwd`/.build go get github.com/go-bindata/go-bindata/...

ui/bindata.go: .build/bin/go-bindata node_modules $(wildcard ui/assets/**/*)
rsync -r ui/assets/* .build/ui
ui/.build/ui: node_modules $(wildcard ui/assets/**/*)
mkdir -p ui/.build
rsync -r ui/assets/* ui/.build/ui
npx webpack $(WEBPACK_ARGS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original motivation around using bindata in the first place is so that we could ensure built static assets were present and usable immediately after go install, without requiring an additional build step / installing node_modules / etc. I'm admittedly fuzzy about whether or not Go Modules have a post-build lifecycle step, but I think that context is important for this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have had success with pkger.

$< -o $@ -pkg ui -prefix .build/ui -nomemcopy .build/ui/...
Comment on lines +23 to -29
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this rule needs some tuning for proper rebuilds.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate more on what you mean here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try. Since ui/.build/ui is a directory, I'm not sure under which circumstances make will figure out that the target needs to be rebuilt. Maybe it would be better to only check the JavaScript bundle generated by webpack?


dev: ALL
npm install
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module github.com/hound-search/hound

go 1.13
go 1.16

require (
github.com/blang/semver v3.5.1+incompatible
github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
)
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
github.com/blang/semver v1.1.0 h1:ol1rO7QQB5uy7umSNV7VAmLugfLRD+17sYJujRNYPhg=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/go-bindata/go-bindata v1.0.0 h1:DZ34txDXWn1DyWa+vQf7V9ANc2ILTtrEjtlsdJRF26M=
github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE=
github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo=
742 changes: 13 additions & 729 deletions ui/bindata.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ module.exports = {
},
output: {
filename: '[name]',
path: path.resolve(__dirname, '.build')
path: path.resolve(__dirname, 'ui/.build')
}
};