delay: fix func stable name to strip gopath prefix (#211)

diff --git a/delay/delay.go b/delay/delay.go
index a5d8186..0a8df62 100644
--- a/delay/delay.go
+++ b/delay/delay.go
@@ -118,14 +118,14 @@
 // For calls from package main: strip all leading path entries, leaving just the filename.
 // For calls from anywhere else, strip $GOPATH/src, leaving just the package path and file path.
 func fileKey(file string) (string, error) {
-	if !internal.IsSecondGen() || internal.MainPath == "" {
+	if !internal.IsSecondGen() {
 		return file, nil
 	}
 	// If the caller is in the same Dir as mainPath, then strip everything but the file name.
 	if filepath.Dir(file) == internal.MainPath {
 		return filepath.Base(file), nil
 	}
-	// If the path contains "_gopath/src/", which is what the builder uses for
+	// If the path contains "gopath/src/", which is what the builder uses for
 	// apps which don't use go modules, strip everything up to and including src.
 	// Or, if the path starts with /tmp/staging, then we're importing a package
 	// from the app's module (and we must be using go modules), and we have a
@@ -133,7 +133,7 @@
 	// including the first /srv/.
 	// And be sure to look at the GOPATH, for local development.
 	s := string(filepath.Separator)
-	for _, s := range []string{filepath.Join("_gopath", "src") + s, s + "srv" + s, filepath.Join(build.Default.GOPATH, "src") + s} {
+	for _, s := range []string{filepath.Join("gopath", "src") + s, s + "srv" + s, filepath.Join(build.Default.GOPATH, "src") + s} {
 		if idx := strings.Index(file, s); idx > 0 {
 			return file[idx+len(s):], nil
 		}
diff --git a/delay/delay_test.go b/delay/delay_test.go
index 06f2912..217af0c 100644
--- a/delay/delay_test.go
+++ b/delay/delay_test.go
@@ -466,7 +466,7 @@
 }
 
 func TestFileKey(t *testing.T) {
-	os.Setenv("GAE_ENV", "standard")
+	const firstGenTest = 0
 	tests := []struct {
 		mainPath string
 		file     string
@@ -499,6 +499,16 @@
 			filepath.FromSlash("/tmp/staging3234/srv/_gopath/src/example.com/bar/main.go"),
 			filepath.FromSlash("example.com/bar/main.go"),
 		},
+		{
+			filepath.FromSlash("/tmp/staging3234/srv/gopath/src/example.com/foo"),
+			filepath.FromSlash("/tmp/staging3234/srv/gopath/src/example.com/bar/main.go"),
+			filepath.FromSlash("example.com/bar/main.go"),
+		},
+		{
+			filepath.FromSlash(""),
+			filepath.FromSlash("/tmp/staging3234/srv/gopath/src/example.com/bar/main.go"),
+			filepath.FromSlash("example.com/bar/main.go"),
+		},
 		// go mod, same package
 		{
 			filepath.FromSlash("/tmp/staging3234/srv"),
@@ -520,6 +530,11 @@
 			filepath.FromSlash("/tmp/staging3234/srv/bar/main.go"),
 			filepath.FromSlash("bar/main.go"),
 		},
+		{
+			filepath.FromSlash(""),
+			filepath.FromSlash("/tmp/staging3234/srv/bar/main.go"),
+			filepath.FromSlash("bar/main.go"),
+		},
 		// go mod, other package
 		{
 			filepath.FromSlash("/tmp/staging3234/srv"),
@@ -528,6 +543,9 @@
 		},
 	}
 	for i, tc := range tests {
+		if i > firstGenTest {
+			os.Setenv("GAE_ENV", "standard")
+		}
 		internal.MainPath = tc.mainPath
 		got, err := fileKey(tc.file)
 		if err != nil {