Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix windows gopath issue #188

Merged
merged 3 commits into from
Jul 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 68 additions & 8 deletions Gopkg.lock

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

34 changes: 34 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: "{build}"

# Source Config

skip_branch_with_pr: true
clone_folder: c:\gopath\src\github.com\vektah\gqlgen

# Build host

environment:
GOPATH: c:\gopath
GOVERSION: 1.10
PATH: '%PATH%;c:\gopath\bin'

init:
- git config --global core.autocrlf input

# Build

install:
# Install the specific Go version.
- rmdir c:\go /s /q
- appveyor DownloadFile https://storage.googleapis.com/golang/go%GOVERSION%.windows-amd64.msi
- msiexec /i go%GOVERSION%.windows-amd64.msi /q
- go version

build: false
deploy: false

test_script:
- go get -u github.com/vektah/gorunpkg github.com/golang/dep/cmd/dep
- dep ensure -vendor-only
- go generate ./...
- go test ./...
9 changes: 5 additions & 4 deletions codegen/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ func (c *PackageConfig) normalize() error {
}

func (c *PackageConfig) ImportPath() string {
dir := c.Dir()
dir := filepath.ToSlash(c.Dir())
for _, gopath := range filepath.SplitList(build.Default.GOPATH) {
gopath = filepath.Join(gopath, "src") + string(os.PathSeparator)
gopath = filepath.ToSlash(gopath) + "/src/"
if len(gopath) > len(dir) {
continue
}
Expand All @@ -109,7 +109,7 @@ func (c *PackageConfig) ImportPath() string {
break
}
}
return filepath.ToSlash(dir)
return dir
}

func (c *PackageConfig) Dir() string {
Expand Down Expand Up @@ -167,7 +167,8 @@ func findCfg() (string, error) {
}

cfg := findCfgInDir(dir)
for cfg == "" && dir != "/" {

for cfg == "" && dir != filepath.Dir(dir) {
dir = filepath.Dir(dir)
cfg = findCfgInDir(dir)
}
Expand Down
2 changes: 1 addition & 1 deletion codegen/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func TestLoadConfig(t *testing.T) {
t.Run("config does not exist", func(t *testing.T) {
_, err := LoadConfig("doesnotexist.yml")
require.EqualError(t, err, "unable to read config: open doesnotexist.yml: no such file or directory")
require.Error(t, err)
})

t.Run("malformed config", func(t *testing.T) {
Expand Down
30 changes: 20 additions & 10 deletions example/dataloader/addressloader_gen.go

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

Loading