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 all commits
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
8 changes: 4 additions & 4 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
on: [push]
on: [push, pull_request]
jobs:
go-build:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.14", "1.13", "1.12"]
go: ["1.16"]
Copy link
Contributor

Choose a reason for hiding this comment

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

While it's true that we probably don't need to be supporting Go 1.12 or 1.13, I'm wary of dropping support for everything but the latest version. I believe the two most recent Go versions are officially supported. This might make a little more sense once Go 1.17 is out.

Copy link

Choose a reason for hiding this comment

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

Walking around and reminding that Go 1.17 was released.

steps:
- uses: actions/[email protected]
- uses: actions/setup-go@v2
Expand All @@ -23,7 +23,7 @@ jobs:
name: lint
strategy:
matrix:
go: ["1.14"]
go: ["1.16"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -36,7 +36,7 @@ jobs:
go-test:
strategy:
matrix:
go: ["1.14", "1.13", "1.12"]
go: ["1.16"]
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Hound is an extremely fast source code search engine. The core is based on this
### Using Go Tools


0. [Install Go](https://golang.org/doc/install) if you don't have it already. Hound requires version 1.4 or later.
0. [Install Go](https://golang.org/doc/install) if you don't have it already. Hound requires version 1.16 or later.
You might also want to define a [`GOPATH`](https://github.com/golang/go/wiki/GOPATH) environment variable)
(it defaults to $HOME/go if you don't explicitly have one set). If everything is installed properly, `go version` should
print out the installed version of go.
Expand Down Expand Up @@ -80,7 +80,7 @@ We've used many similar tools in the past, and most of them are either too slow,
Which brings us to...

## Requirements
* Go 1.13+
* Go 1.16+

Yup, that's it. You can proxy requests to the Go service through Apache/nginx/etc., but that's not required.

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=
Empty file added ui/.build/ui/.gitkeep
Empty file.
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')
}
};