diff --git a/.travis.yml b/.travis.yml index 28ca8bf..06be2ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,3 +25,4 @@ notifications: env: global: - MAKEFLAGS=" -j 2" + - GO111MODULE=on diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index 6b3c51f..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,48 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - digest = "1:0deddd908b6b4b768cfc272c16ee61e7088a60f7fe2f06c547bd3d8e1f8b8e77" - name = "github.com/davecgh/go-spew" - packages = ["spew"] - pruneopts = "" - revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" - version = "v1.1.1" - -[[projects]] - digest = "1:256484dbbcd271f9ecebc6795b2df8cad4c458dd0f5fd82a8c2fa0c29f233411" - name = "github.com/pmezard/go-difflib" - packages = ["difflib"] - pruneopts = "" - revision = "792786c7400a136282c1664665ae0a8db921c6c2" - version = "v1.0.0" - -[[projects]] - digest = "1:711eebe744c0151a9d09af2315f0bb729b2ec7637ef4c410fa90a18ef74b65b6" - name = "github.com/stretchr/objx" - packages = ["."] - pruneopts = "" - revision = "477a77ecc69700c7cdeb1fa9e129548e1c1c393c" - version = "v0.1.1" - -[[projects]] - digest = "1:c587772fb8ad29ad4db67575dad25ba17a51f072ff18a22b4f0257a4d9c24f75" - name = "github.com/stretchr/testify" - packages = [ - "assert", - "mock", - ] - pruneopts = "" - revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686" - version = "v1.2.2" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - input-imports = [ - "github.com/davecgh/go-spew/spew", - "github.com/pmezard/go-difflib/difflib", - "github.com/stretchr/testify/mock", - ] - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index 6746e64..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,30 +0,0 @@ - -# Gopkg.toml example -# -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" - - -[[constraint]] - name = "github.com/davecgh/go-spew" - version = "1.1.0" - -[[constraint]] - name = "github.com/pmezard/go-difflib" - version = "1.0.0" diff --git a/Makefile b/Makefile index 2b74639..a825c88 100644 --- a/Makefile +++ b/Makefile @@ -4,19 +4,14 @@ install: get_dependencies install_linters .PHONY: get_dependencies get_dependencies: go get github.com/mattn/goveralls - go get github.com/golang/dep/cmd/dep - $(GOPATH)/bin/dep ensure .PHONY: install_linters install_linters: - go get -u github.com/alecthomas/gometalinter - $(GOPATH)/bin/gometalinter --install + curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.12.5 .PHONY: lint lint: - $(GOPATH)/bin/gometalinter \ - --disable=gosec \ - --vendor ./... + $(GOPATH)/bin/golangci-lint run .PHONY: test test: lint diff --git a/examples/advanced_test.go b/examples/advanced_test.go index 5cc14b3..798a27d 100644 --- a/examples/advanced_test.go +++ b/examples/advanced_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/bradleyjkemp/cupaloy" + "github.com/bradleyjkemp/cupaloy/v2" "github.com/stretchr/testify/mock" ) @@ -48,7 +48,7 @@ func TestConfig(t *testing.T) { // If a snapshot is updated then this returns an error // This is to prevent you accidentally updating your snapshots in CI func TestUpdate(t *testing.T) { - snapshotter := cupaloy.New(cupaloy.EnvVariableName("GOPATH")) + snapshotter := cupaloy.New(cupaloy.EnvVariableName("HOME")) err := snapshotter.Snapshot("Hello world") if err != nil { @@ -176,7 +176,7 @@ func TestGlobalCreateNewAutomatically(t *testing.T) { } func TestFailOnUpdate(t *testing.T) { - snapshotter := cupaloy.New(cupaloy.EnvVariableName("GOPATH"), cupaloy.FailOnUpdate(false)) + snapshotter := cupaloy.New(cupaloy.EnvVariableName("HOME"), cupaloy.FailOnUpdate(false)) err := snapshotter.Snapshot("Hello new world") if err != nil { diff --git a/examples/basic_test.go b/examples/basic_test.go index d76efbd..305248e 100644 --- a/examples/basic_test.go +++ b/examples/basic_test.go @@ -3,7 +3,7 @@ package examples import ( "testing" - "github.com/bradleyjkemp/cupaloy" + "github.com/bradleyjkemp/cupaloy/v2" ) func TestString(t *testing.T) { diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..b0770c7 --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module github.com/bradleyjkemp/cupaloy/v2 + +require ( + github.com/davecgh/go-spew v1.1.1 + github.com/pmezard/go-difflib v1.0.0 + github.com/stretchr/objx v0.1.1 // indirect + github.com/stretchr/testify v1.2.2 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..604d09f --- /dev/null +++ b/go.sum @@ -0,0 +1,8 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/util.go b/util.go index 1e192e7..d1fde20 100644 --- a/util.go +++ b/util.go @@ -59,12 +59,12 @@ func takeV1Snapshot(i ...interface{}) string { func takeSnapshot(i ...interface{}) string { snapshot := &bytes.Buffer{} for _, v := range i { - switch v.(type) { + switch vt := v.(type) { case string: - snapshot.WriteString(v.(string)) + snapshot.WriteString(vt) snapshot.WriteString("\n") case []byte: - snapshot.Write(v.([]byte)) + snapshot.Write(vt) snapshot.WriteString("\n") default: spewConfig.Fdump(snapshot, v)