Skip to content

Commit

Permalink
go.mod can be anywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
kolaente committed Dec 7, 2018
1 parent 878f96d commit 00c9ee5
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions xgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,6 @@ func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string
// Resolve the repository import path from the file path
config.Repository = resolveImportPath(config.Repository)

// Check if the repo uses go 1.11 modules by determening if it has a go.mod file
if _, err := os.Stat(config.Repository + "/go.mod"); !os.IsNotExist(err) {
usesModules = true

// Check if it has a vendor folder to use that when building with mod
vendorfolder, err := os.Stat(config.Repository + "/vendor")
if !os.IsNotExist(err) && vendorfolder.Mode().IsDir() {
// TODO: how to pass -mod=vendor to the build script?
}
}

// Iterate over all the local libs and export the mount points
if os.Getenv("GOPATH") == "" && !usesModules {
log.Fatalf("No $GOPATH is set or forwarded to xgo")
Expand Down Expand Up @@ -278,6 +267,10 @@ func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string
if filepath.HasPrefix(target, sources) {
return nil
}
// Check if the repo uses go 1.11 modules by determening if it has a go.mod file
if _, err := os.Stat(path + "/go.mod"); !os.IsNotExist(err) && !usesModules {
usesModules = true
}
// Folder needs explicit mounting due to docker symlink security
locals = append(locals, target)
mounts = append(mounts, filepath.Join("/ext-go", strconv.Itoa(len(locals)), "src", strings.TrimPrefix(path, sources)))
Expand Down Expand Up @@ -318,6 +311,12 @@ func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string

if usesModules {
args = append(args, []string{"-e", "GO111MODULE=on"}...)

// Check if it has a vendor folder to use that when building with mod
vendorfolder, err := os.Stat(config.Repository + "/vendor")
if !os.IsNotExist(err) && vendorfolder.Mode().IsDir() {
// TODO: how to pass -mod=vendor to the build script?
}
}

args = append(args, []string{image, config.Repository}...)
Expand Down

0 comments on commit 00c9ee5

Please sign in to comment.