Browse Source

remove duplicate go:generate directive

I hadn't noticed that cmd/bundle prints its own go:generate directive.
I guess that makes sense for the average user running it directly,
but that doesn't apply to us, and we end up with duplicate directives.

Before:

	$ go generate -n
	bundle -o cmdgo_quoted.go -prefix cmdgoQuoted cmd/internal/quoted
	go run golang.org/x/tools/cmd/bundle@v0.1.9 -o cmdgo_quoted.go -prefix cmdgoQuoted cmd/internal/quoted

After:

	$ go generate -n
	go run golang.org/x/tools/cmd/bundle@v0.1.9 -o cmdgo_quoted.go -prefix cmdgoQuoted cmd/internal/quoted
	sed -i /go:generate/d cmdgo_quoted.go

While here, I made a typo in the last release notes, because of course.
I already edited that out in the GitHub release.
Daniel Martí 4 months ago
parent
commit
0b6769c807
3 changed files with 5 additions and 2 deletions
  1. 1 1
      CHANGELOG.md
  2. 0 1
      cmdgo_quoted.go
  3. 4 0
      main.go

+ 1 - 1
CHANGELOG.md

@@ -10,7 +10,7 @@ Noteworthy changes include:
 * Obfuscation is now fully deterministic with a fixed `-seed` - [#449]
 * Improve support for type aliases to fix some build failures - [#466]
 * Add support for quotes in `-ldflags` as per `go help build` - [#492]
-* Fail if the current Go version is newer than what build garble - [#269]
+* Fail if the current Go version is newer than what built garble - [#269]
 * Various optimizations resulting in builds being up to 5% faster - [#456]
 
 ## [v0.5.1] - 2022-01-18

+ 0 - 1
cmdgo_quoted.go

@@ -1,5 +1,4 @@
 // Code generated by golang.org/x/tools/cmd/bundle. DO NOT EDIT.
-//go:generate bundle -o cmdgo_quoted.go -prefix cmdgoQuoted cmd/internal/quoted
 
 // Package quoted provides string manipulation utilities.
 //

+ 4 - 0
main.go

@@ -1157,7 +1157,11 @@ func (tf *transformer) findReflectFunctions(files []*ast.File) {
 	}
 }
 
+// cmd/bundle will include a go:generate directive in its output by default.
+// Ours specifies a version and doesn't assume bundle is in $PATH, so drop it.
+
 //go:generate go run golang.org/x/tools/cmd/bundle@v0.1.9 -o cmdgo_quoted.go -prefix cmdgoQuoted cmd/internal/quoted
+//go:generate sed -i /go:generate/d cmdgo_quoted.go
 
 // prefillObjectMaps collects objects which should not be obfuscated,
 // such as those used as arguments to reflect.TypeOf or reflect.ValueOf.