Skip to content

Commit

Permalink
Build a binary with an expected name (#446)
Browse files Browse the repository at this point in the history
Changes introduced in #410 is breaking backward compatibility
for building binaries with an expected name.
  • Loading branch information
aminjam committed May 31, 2021
1 parent dbc6ecd commit 7356360
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
6 changes: 1 addition & 5 deletions gexec/build.go
Expand Up @@ -3,8 +3,6 @@
package gexec

import (
"crypto/md5"
"encoding/hex"
"errors"
"fmt"
"go/build"
Expand Down Expand Up @@ -197,9 +195,7 @@ func newExecutablePath(gopath, packagePath string, suffixes ...string) (string,
return "", errors.New("$GOPATH not provided when building " + packagePath)
}

hash := md5.Sum([]byte(packagePath))
filename := fmt.Sprintf("%s-%x%s", path.Base(packagePath), hex.EncodeToString(hash[:]), strings.Join(suffixes, ""))
executable := filepath.Join(tmpDir, filename)
executable := filepath.Join(tmpDir, path.Base(packagePath))

if runtime.GOOS == "windows" {
executable += ".exe"
Expand Down
1 change: 1 addition & 0 deletions gexec/build_test.go
Expand Up @@ -24,6 +24,7 @@ var _ = Describe(".Build", func() {
compiledPath, err := gexec.Build(packagePath)
Expect(err).ShouldNot(HaveOccurred())
Expect(compiledPath).Should(BeAnExistingFile())
Expect(filepath.Base(compiledPath)).Should(MatchRegexp(`firefly(|.exe)$`))
})

Context("and CleanupBuildArtifacts has been called", func() {
Expand Down

0 comments on commit 7356360

Please sign in to comment.