env GOPRIVATE=match-absolutely/nothing
! garble build -o=out ./standalone
stderr '^GOPRIVATE="match-absolutely/nothing" does not match any packages to be built$'

env GOPRIVATE=test/main/imported
! garble build ./importer
stderr '^public package "test/main/importer" can''t depend on obfuscated package "test/main/imported" \(matched via GOPRIVATE="test/main/imported"\)$'

[short] stop # rebuilding std is slow

env GOPRIVATE='*'

# Try garbling all of std, given some std packages.
# No need for a main package here; building the std packages directly works the
# same, and is faster as we don't need to link a binary.
# This used to cause multiple errors, mainly since std vendors some external
# packages so we must properly support ImportMap.
# Plus, some packages like net make heavy use of complex features like Cgo.
# Note that we won't obfuscate a few std packages just yet, mainly those around runtime.
garble build std

# Link a binary importing net/http, which will catch whether or not we
# support ImportMap when linking.
garble build -o=out ./stdimporter

-- go.mod --
module test/main

go 1.16
-- standalone/main.go --
package main

func main() {}
-- importer/importer.go --
package importer

import "test/main/imported"

var _ = imported.Name
-- imported/imported.go --
package imported

var Name = "value"
-- stdimporter/main.go --
package main

import "net/http"

func main() {
	http.ListenAndServe("", nil)
}
