From 960446d969ed16db69f9e55f49fb25ee95e8564e Mon Sep 17 00:00:00 2001 From: Gianluca Mondini Date: Mon, 30 Sep 2024 10:51:55 +0200 Subject: [PATCH] all: use the syntax `//go:build` instead of `// +build` This commit removes the line syntax: // +build by using just the syntax: //go:build which is supported starting from Go 1.17 and has been considered deprecated starting from Go 1.18. Note that, in tests, the old syntax is kept. See #956. --- cmd/scriggo/generate.go | 1 - playground/scriggo.wasm.go | 1 - test/compare/cgo_off.go | 1 - test/compare/cgo_on.go | 1 - test/compare/run.go | 7 +++++-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/scriggo/generate.go b/cmd/scriggo/generate.go index d449cbeab..fae860aa7 100644 --- a/cmd/scriggo/generate.go +++ b/cmd/scriggo/generate.go @@ -202,7 +202,6 @@ func renderPackages(w io.Writer, dir string, sf *scriggofile, goos string, flags // Skeleton for a package group. const pkgsSkeleton = `// Code generated by scriggo command. DO NOT EDIT. //go:build {{.GOOS}} && {{.BaseVersion}} && !{{.NextGoVersion}} -// +build {{.GOOS}},{{.BaseVersion}},!{{.NextGoVersion}} package {{.Name}} diff --git a/playground/scriggo.wasm.go b/playground/scriggo.wasm.go index 94eacb6ef..1fc88476b 100644 --- a/playground/scriggo.wasm.go +++ b/playground/scriggo.wasm.go @@ -1,5 +1,4 @@ //go:build js && wasm -// +build js,wasm package main diff --git a/test/compare/cgo_off.go b/test/compare/cgo_off.go index 554393101..b269d525b 100644 --- a/test/compare/cgo_off.go +++ b/test/compare/cgo_off.go @@ -1,5 +1,4 @@ //go:build !cgo -// +build !cgo package main diff --git a/test/compare/cgo_on.go b/test/compare/cgo_on.go index 44d6bfa8c..871e82f47 100644 --- a/test/compare/cgo_on.go +++ b/test/compare/cgo_on.go @@ -1,5 +1,4 @@ //go:build cgo -// +build cgo package main diff --git a/test/compare/run.go b/test/compare/run.go index 7e55d8422..6642504ff 100644 --- a/test/compare/run.go +++ b/test/compare/run.go @@ -414,8 +414,11 @@ func goldenCompare(testPath string, got []byte) error { return nil } -// isBuildConstraints reports whether line is a build contrain, as specified at -// https://pkg.go.dev/go/build#hdr-Build_Constraints. +// isBuildConstraints reports whether line is a build constraint, as specified +// at https://pkg.go.dev/go/build#hdr-Build_Constraints. +// +// TODO(Gianluca): this function still needs to support the old format of build +// tags. Please refer to the issue https://github.com/open2b/scriggo/issues/956. func isBuildConstraints(line string) bool { line = strings.TrimSpace(line) if !strings.HasPrefix(line, "//") {