-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for stable Func keys in App Engine second gen (#184)
Func keys include the filename where the Func is created. The filename is parsed according to these rules: * Paths in package main are shortened to just the file name (github.com/foo/foo.go -> foo.go) * Paths are stripped to just package paths (/go/src/github.com/foo/bar.go -> github.com/foo/bar.go) * Module versions are stripped (/go/pkg/mod/github.com/foo/bar@v0.0.0-20181026220418-f595d03440dc/baz.go -> github.com/foo/bar/baz.go)
- Loading branch information
Showing
6 changed files
with
185 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,6 @@ import ( | |
) | ||
|
||
func Main() { | ||
MainPath = "" | ||
appengine_internal.Main() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package internal | ||
|
||
// MainPath stores the file path of the main package. On App Engine Standard | ||
// using Go version 1.9 and below, this will be unset. On App Engine Flex and | ||
// App Engine Standard second-gen (Go 1.11 and above), this will be the | ||
// filepath to package main. | ||
var MainPath string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// +build !appengine | ||
|
||
package internal | ||
|
||
import ( | ||
"go/build" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func TestFindMainPath(t *testing.T) { | ||
// Tests won't have package main, instead they have testing.tRunner | ||
want := filepath.Join(build.Default.GOROOT, "src", "testing", "testing.go") | ||
got := findMainPath() | ||
if want != got { | ||
t.Errorf("findMainPath: want %s, got %s", want, got) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters