Repository: google/starlark-go (go)

Issue:
Change `starlarktest/assert.go` back to an actual file
https://github.com/google/starlark-go/blob/fae38c8a6d89dc410be86b76dfff475b29dba878/starlarktest/assert.go#L3-L5

Now that `fs.Embed` is mature enough, should we move this back to an actual file?

Pull request description:
Convert `assert.go` back to `assert.star` and bump Go version to 1.16.
This PR converts `assert.go` back to an actual starlark file `assert.star` and use `embed.FS` to embed the file. As part of this change, we are bumping Go version from 1.13 to 1.16 for `embed.FS` support.

Fixes #451 



Patch:
diff --git a/go.mod b/go.mod
index 99a5585..51c19f5 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module go.starlark.net
 
-go 1.13
+go 1.16
 
 require (
 	github.com/chzyer/logex v1.1.10 // indirect


Test patch:
diff --git a/starlarktest/assert.go b/starlarktest/assert.star
similarity index 88%
rename from starlarktest/assert.go
rename to starlarktest/assert.star
index f18719c..c6e480f 100644
--- a/starlarktest/assert.go
+++ b/starlarktest/assert.star
@@ -1,9 +1,3 @@
-package starlarktest
-
-// assertStar contains the logical data file assert.star.
-// TODO(adonovan): move it back into an actual file,
-// when fs.Embed is more than two releases old.
-const assertStar = `
 # Predeclared built-ins for this module:
 #
 # error(msg): report an error in Go's test framework without halting execution.
@@ -55,4 +49,3 @@ assert = module(
     contains = _contains,
     fails = _fails,
 )
-`
diff --git a/starlarktest/starlarktest.go b/starlarktest/starlarktest.go
index afd1e90..3a19f04 100644
--- a/starlarktest/starlarktest.go
+++ b/starlarktest/starlarktest.go
@@ -13,6 +13,7 @@
 package starlarktest // import "go.starlark.net/starlarktest"
 
 import (
+	_ "embed"
 	"fmt"
 	"os"
 	"path/filepath"
@@ -50,9 +51,11 @@ func GetReporter(thread *starlark.Thread) Reporter {
 }
 
 var (
-	once      sync.Once
-	assert    starlark.StringDict
-	assertErr error
+	once   sync.Once
+	assert starlark.StringDict
+	//go:embed assert.star
+	assertFileSrc string
+	assertErr     error
 )
 
 // LoadAssertModule loads the assert module.
@@ -66,10 +69,8 @@ func LoadAssertModule() (starlark.StringDict, error) {
 			"module":  starlark.NewBuiltin("module", starlarkstruct.MakeModule),
 			"_freeze": starlark.NewBuiltin("freeze", freeze),
 		}
-		// TODO(adonovan): embed the file using embed.FS when we can rely on go1.16,
-		// and make the apparent filename reference that file.
 		thread := new(starlark.Thread)
-		assert, assertErr = starlark.ExecFile(thread, "builtins/assert.star", assertStar, predeclared)
+		assert, assertErr = starlark.ExecFile(thread, "assert.star", assertFileSrc, predeclared)
 	})
 	return assert, assertErr
 }