diff --git a/go.mod b/go.mod index 510ee527..f362b179 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,13 @@ module github.com/moov-io/infra go 1.21 -require goftp.io/server v0.4.1 +require ( + github.com/stretchr/testify v1.8.3 + goftp.io/server v0.4.1 +) require ( + github.com/davecgh/go-spew v1.1.1 // indirect github.com/jlaffaye/ftp v0.2.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect @@ -14,10 +18,11 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/stretchr/testify v1.8.3 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/crypto v0.12.0 // indirect golang.org/x/net v0.14.0 // indirect golang.org/x/sys v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 8e6904eb..03e37ac9 100644 --- a/go.sum +++ b/go.sum @@ -75,6 +75,8 @@ golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= diff --git a/tests/go/panic_test.go b/tests/go/panic_test.go new file mode 100644 index 00000000..666e77b2 --- /dev/null +++ b/tests/go/panic_test.go @@ -0,0 +1,41 @@ +package go_test + +import ( + "regexp" + "strings" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestPanicLinter(t *testing.T) { + // The follow snippets of code should be allowed through by the go/lint-project.sh script. + r := regexp.MustCompile(`([a-z]+)`) + require.True(t, r.MatchString("abc")) + + var out string + func() { + defer func() { + caught := recover() + if ss, ok := caught.(string); ok { + out = ss + } + }() + require.Equal(t, "", strings.Repeat("Z", -1)) + }() + require.Equal(t, "strings: negative Repeat count", out) + + f := &foo{} + f.panic("whoops") + + // call panic but allow it + require.Panics(t, func() { + panic("bad thing") //nolint:forbidigo + }) +} + +type foo struct{} + +func (*foo) panic(desc string) { + // send PD alert or something +}