This commit is contained in:
Ivan Trubach 2025-06-20 15:36:43 -04:00 committed by GitHub
commit cd492f61dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 40 additions and 0 deletions

View File

@ -239,6 +239,10 @@ func runGenerate(ctx context.Context, cmd *base.Command, args []string) {
func generate(absFile string) bool {
src, err := os.ReadFile(absFile)
if err != nil {
if os.IsNotExist(err) {
// Disappeared during generation - ignore file.
return true
}
log.Fatalf("generate: %s", err)
}

View File

@ -0,0 +1,36 @@
# Install an rm command because some systems don't have it.
env GOBIN=$WORK/tmp/bin
go install rm.go
[plan9] env path=$GOBIN${:}$path
[!plan9] env PATH=$GOBIN${:}$PATH
go generate ./...
-- go.mod --
module genclean
go 1.16
-- a.go --
package genclean
//go:generate rm b.go
-- b.go --
package genclean
-- rm.go --
// +build ignore
package main
import (
"log"
"os"
)
func main() {
if err := os.Remove(os.Args[1]); err != nil {
log.Fatal(err)
}
}