Skip to content

Commit

Permalink
Use Go modules for gofiles (#12)
Browse files Browse the repository at this point in the history
Set up gofiles package to use modules.
  • Loading branch information
nmiyake authored Nov 17, 2019
1 parent 4d4a292 commit a4e257e
Show file tree
Hide file tree
Showing 20 changed files with 416 additions and 280 deletions.
56 changes: 0 additions & 56 deletions gofiles/Gopkg.lock

This file was deleted.

38 changes: 0 additions & 38 deletions gofiles/Gopkg.toml

This file was deleted.

8 changes: 8 additions & 0 deletions gofiles/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/nmiyake/pkg/gofiles

go 1.13

require (
github.com/nmiyake/pkg/dirs v1.0.0
github.com/stretchr/testify v1.4.0
)
13 changes: 13 additions & 0 deletions gofiles/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/nmiyake/pkg/dirs v1.0.0 h1:pYeIw1wH7jh5/ew8naGE4Q56byJG7Uyi8PwwhVe/MTg=
github.com/nmiyake/pkg/dirs v1.0.0/go.mod h1:r6/PkZ3CA1szGfQkxcHheEjBWi6Zu6jLb+lQmRXEyvM=
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.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
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/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
9 changes: 6 additions & 3 deletions gofiles/godel/config/godel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ plugins:
- https://palantir.bintray.com/releases/{{GroupPath}}/{{Product}}/{{Version}}/{{Product}}-{{Version}}-{{OS}}-{{Arch}}.tgz
plugins:
- locator:
id: com.palantir.godel-dep-plugin:dep-plugin:1.1.0
id: com.palantir.godel-mod-plugin:mod-plugin:1.0.1
checksums:
darwin-amd64: 946b0def510a7e94b46bb635a67f00c05243505e2a2ef9b0b7dab45b0437be1f
linux-amd64: cc2729e7f25c0121f841e237238c11514ee4c1376c458a1c4997ee86de17b209
darwin-amd64: df22922bacfe4e4e7c255607a0aace176205f04ae001f3746276fcfab1780e01
linux-amd64: a2697b3d504bb37c2fd8831a66c7014927a6d94e4dfb9765b4764354370a1ab6
environment:
GO111MODULE: "on"
GOFLAGS: "-mod=vendor"
exclude:
names:
- "\\..+"
Expand Down
33 changes: 33 additions & 0 deletions gofiles/gofiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package gofiles_test

import (
"os"
"os/exec"
"testing"

Expand All @@ -33,6 +34,12 @@ import (
)

func TestWriteGoFiles(t *testing.T) {
restoreEnvVars := setEnvVars(map[string]string{
"GO111MODULE": "off",
"GOFLAGS": "",
})
defer restoreEnvVars()

dir, cleanup, err := dirs.TempDir(".", "")
require.NoError(t, err)
defer cleanup()
Expand Down Expand Up @@ -72,3 +79,29 @@ func Baz() string {

assert.Equal(t, "bar baz\n", string(output))
}

func setEnvVars(envVars map[string]string) func() {
origVars := make(map[string]string)
var unsetVars []string
for k := range envVars {
val, ok := os.LookupEnv(k)
if !ok {
unsetVars = append(unsetVars, k)
continue
}
origVars[k] = val
}

for k, v := range envVars {
_ = os.Setenv(k, v)
}

return func() {
for _, k := range unsetVars {
_ = os.Unsetenv(k)
}
for k, v := range origVars {
_ = os.Setenv(k, v)
}
}
}
2 changes: 1 addition & 1 deletion gofiles/vendor/github.com/davecgh/go-spew/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a4e257e

Please sign in to comment.