From 03a935faf8d2410f083c6538b1e2aa09dca87b34 Mon Sep 17 00:00:00 2001 From: arif emre Date: Fri, 6 Jan 2017 16:12:32 +0200 Subject: [PATCH 1/2] Update build.go Fixed the build error in Windows operating systems. --- buffalo/cmd/build.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/buffalo/cmd/build.go b/buffalo/cmd/build.go index 339a636b8..cfc1e9c18 100644 --- a/buffalo/cmd/build.go +++ b/buffalo/cmd/build.go @@ -31,6 +31,7 @@ import ( "regexp" "strings" "time" + "runtime" "github.com/gobuffalo/velvet" "github.com/spf13/cobra" @@ -146,8 +147,8 @@ func (b *builder) buildRiceZip() error { } rx := regexp.MustCompile("(rice.FindBox|rice.MustFindBox)") if rx.Match(s) { - gopath := filepath.Join(os.Getenv("GOPATH"), "src") - pkg := filepath.Dir(strings.Replace(path, gopath+"/", "", -1)) + gopath := strings.Replace(filepath.Join(os.Getenv("GOPATH"), "src"), "\\", "/", -1) + pkg := strings.Replace(filepath.Dir(strings.Replace(path, gopath+"/", "", -1)), "\\", "/", -1) paths[pkg] = true } } @@ -219,9 +220,10 @@ func (b *builder) buildMain() error { } ctx := velvet.NewContext() ctx.Set("root", root) - ctx.Set("modelsPack", filepath.Join(packagePath(root), "models")) - ctx.Set("aPack", filepath.Join(packagePath(root), "a")) + ctx.Set("modelsPack", packagePath(root)+"/models") + ctx.Set("aPack", packagePath(root)+"/a") ctx.Set("name", filepath.Base(root)) + s, err := velvet.Render(buildMainTmpl, ctx) if err != nil { return err @@ -328,7 +330,13 @@ var buildCmd = &cobra.Command{ func init() { RootCmd.AddCommand(buildCmd) pwd, _ := os.Getwd() - buildCmd.Flags().StringVarP(&outputBinName, "output", "o", filepath.Join("bin", filepath.Base(pwd)), "set the name of the binary") + + output := filepath.Join("bin", filepath.Base(pwd)) + if runtime.GOOS == "windows" { + output += ".exe" + } + buildCmd.Flags().StringVarP(&outputBinName, "output", "o", output, "set the name of the binary") + buildCmd.Flags().BoolVarP(&zipBin, "zip", "z", false, "zips the assets to the binary, this requires zip installed") } From 3a66b41d3f438146e1cd5f81b165343d7314aa47 Mon Sep 17 00:00:00 2001 From: arif emre Date: Fri, 6 Jan 2017 16:32:58 +0200 Subject: [PATCH 2/2] Update build.go --- buffalo/cmd/build.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/buffalo/cmd/build.go b/buffalo/cmd/build.go index cfc1e9c18..bcc603255 100644 --- a/buffalo/cmd/build.go +++ b/buffalo/cmd/build.go @@ -23,18 +23,17 @@ package cmd import ( "bytes" "fmt" + "github.com/gobuffalo/velvet" + "github.com/spf13/cobra" "io" "io/ioutil" "os" "os/exec" "path/filepath" "regexp" + "runtime" "strings" "time" - "runtime" - - "github.com/gobuffalo/velvet" - "github.com/spf13/cobra" ) var outputBinName string @@ -147,7 +146,7 @@ func (b *builder) buildRiceZip() error { } rx := regexp.MustCompile("(rice.FindBox|rice.MustFindBox)") if rx.Match(s) { - gopath := strings.Replace(filepath.Join(os.Getenv("GOPATH"), "src"), "\\", "/", -1) + gopath := strings.Replace(filepath.Join(os.Getenv("GOPATH"), "src"), "\\", "/", -1) pkg := strings.Replace(filepath.Dir(strings.Replace(path, gopath+"/", "", -1)), "\\", "/", -1) paths[pkg] = true } @@ -223,7 +222,6 @@ func (b *builder) buildMain() error { ctx.Set("modelsPack", packagePath(root)+"/models") ctx.Set("aPack", packagePath(root)+"/a") ctx.Set("name", filepath.Base(root)) - s, err := velvet.Render(buildMainTmpl, ctx) if err != nil { return err @@ -330,13 +328,13 @@ var buildCmd = &cobra.Command{ func init() { RootCmd.AddCommand(buildCmd) pwd, _ := os.Getwd() - - output := filepath.Join("bin", filepath.Base(pwd)) + output := filepath.Join("bin", filepath.Base(pwd)) + if runtime.GOOS == "windows" { output += ".exe" } + buildCmd.Flags().StringVarP(&outputBinName, "output", "o", output, "set the name of the binary") - buildCmd.Flags().BoolVarP(&zipBin, "zip", "z", false, "zips the assets to the binary, this requires zip installed") }