Skip to content

Commit f8f1173

Browse files
bhavikkumarbmoffatt
authored andcommitted
Add go module support (#189)
* Modify panic test by using a slice of the path directories * Add go module files * Add job which uses go modules but is allowed to fail * Add test for length and order of the path * Simplify testing of frame path to be similar style to original * Use build matrix for go modules in attempt to speed up the build * Revert accidental line change * Tidy go module files * Fix module name
1 parent 43eb3b9 commit f8f1173

File tree

4 files changed

+41
-10
lines changed

4 files changed

+41
-10
lines changed

.travis.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,18 @@ install:
1515
- go get github.com/haya14busa/goverage
1616

1717
matrix:
18+
include:
19+
- go: 1.12
20+
env: GO111MODULE=on
21+
before_install:
22+
- go mod download
23+
install:
24+
- go get golang.org/x/lint/golint
25+
- go get github.com/haya14busa/goverage
1826
allow_failures:
1927
- go: tip
28+
- go: 1.12
29+
env: GO111MODULE=on
2030
fast_finish: true
2131

2232
notifications:
@@ -33,4 +43,4 @@ script:
3343
- golint $LINT_PKGS # lint - ignore failures for now
3444

3545
after_success:
36-
- bash <(curl -s https://codecov.io/bash)
46+
- bash <(curl -s https://codecov.io/bash)

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/aws/aws-lambda-go
2+
3+
go 1.12
4+
5+
require (
6+
github.com/davecgh/go-spew v1.1.0 // indirect
7+
github.com/pmezard/go-difflib v1.0.0 // indirect
8+
github.com/stretchr/testify v1.2.1
9+
gopkg.in/urfave/cli.v1 v1.20.0
10+
)

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
2+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5+
github.com/stretchr/testify v1.2.1 h1:52QO5WkIUcHGIR7EnGagH88x1bUzqGXTC5/1bDTUQ7U=
6+
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
7+
gopkg.in/urfave/cli.v1 v1.20.0 h1:NdAVW6RYxDif9DhDHaAortIu956m2c0v+09AZBPTbE0=
8+
gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0=

lambda/panic_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ func testRuntimeStackTrace(t *testing.T) {
112112
assert.NoError(t, err)
113113

114114
frame := panicInfo.StackTrace[0]
115+
115116
assert.Equal(t, packagePath+"/panic_test.go", frame.Path)
116117
assert.True(t, frame.Line > 0)
117118
assert.Equal(t, "testRuntimeStackTrace", frame.Label)
@@ -123,14 +124,16 @@ func getPackagePath() (string, error) {
123124
return "", err
124125
}
125126

126-
basePath := os.Getenv("GOPATH")
127-
if basePath == "" {
128-
if runtime.GOOS == "windows" {
129-
basePath = os.Getenv("USERPROFILE") + "/go"
130-
} else {
131-
basePath = os.Getenv("HOME") + "/go"
132-
}
127+
var paths []string
128+
if runtime.GOOS == "windows" {
129+
paths = strings.Split(fullPath, "\\")
130+
} else {
131+
paths = strings.Split(fullPath, "/")
132+
}
133+
134+
// The frame.Path will only contain the last 5 directories if there are more than 5 directories.
135+
if len(paths) >= 5 {
136+
paths = paths[len(paths)-4:]
133137
}
134-
basePath = strings.Split(basePath, ":")[0]
135-
return strings.Replace(fullPath, basePath+"/src/", "", 1), nil
138+
return strings.Join(paths, "/"), nil
136139
}

0 commit comments

Comments
 (0)