Skip to content

Fix golangci-lint errors #341

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

Merged
merged 1 commit into from
Jun 17, 2022
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
7 changes: 3 additions & 4 deletions internal/builders/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,17 @@ func main() {

switch os.Args[1] {
case buildCmd.Name():
buildCmd.Parse(os.Args[2:])
check(buildCmd.Parse(os.Args[2:]))
if len(buildCmd.Args()) < 1 {
usage(os.Args[0])
}
configFile := buildCmd.Args()[0]
evaluatedEnvs := buildCmd.Args()[1]

err := runBuild(*buildDry, configFile, evaluatedEnvs)
check(err)
check(runBuild(*buildDry, configFile, evaluatedEnvs))

case provenanceCmd.Name():
provenanceCmd.Parse(os.Args[2:])
check(provenanceCmd.Parse(os.Args[2:]))
// Note: *provenanceEnv may be empty.
if *provenanceName == "" || *provenanceDigest == "" ||
*provenanceCommand == "" || *provenanceWorkingDir == "" {
Expand Down
4 changes: 3 additions & 1 deletion internal/builders/go/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ func (r *run) end() string {
os.Stdout = r.oldStdout

var buf bytes.Buffer
io.Copy(&buf, r.rPipe)
if _, err := io.Copy(&buf, r.rPipe); err != nil {
panic(err)
}
s := buf.String()

r.oldStdout = nil
Expand Down
2 changes: 1 addition & 1 deletion internal/builders/go/pkg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type goReleaserConfigFile struct {
Env []string `yaml:"env"`
Flags []string `yaml:"flags"`
Ldflags []string `yaml:"ldflags"`
Binary string `yaml:"binary`
Binary string `yaml:"binary"`
Version int `yaml:"version"`
Main *string `yaml:"main"`
Dir *string `yaml:"dir"`
Expand Down
20 changes: 0 additions & 20 deletions internal/builders/go/pkg/marshall.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,3 @@ func marshallToBytes(args interface{}) ([]byte, error) {
}
return []byte(encoded), nil
}

// TODO: use generics to support any type.
func unmarshallList(arg string) ([]string, error) {
var res []string
// If argument is empty, return an empty list early,
// because `json.Unmarshal` would fail.
if arg == "" {
return res, nil
}

cs, err := base64.StdEncoding.DecodeString(arg)
if err != nil {
return res, fmt.Errorf("base64.StdEncoding.DecodeString: %w", err)
}

if err := json.Unmarshal(cs, &res); err != nil {
return []string{}, fmt.Errorf("json.Unmarshal: %w", err)
}
return res, nil
}
4 changes: 0 additions & 4 deletions internal/builders/go/pkg/provenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ import (
)

const (
parametersVersion int = 1
buildConfigVersion int = 1
buildType = "https://github.com/slsa-framework/slsa-github-generator/go@v1"
requestTokenEnvKey = "ACTIONS_ID_TOKEN_REQUEST_TOKEN"
requestURLEnvKey = "ACTIONS_ID_TOKEN_REQUEST_URL"
audience = "slsa-framework/slsa-github-generator"
)

type (
Expand Down
9 changes: 0 additions & 9 deletions internal/builders/go/pkg/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ func pathIsUnderCurrentDirectory(path string) error {
return nil
}

func isDirectory(path string) (bool, error) {
fileInfo, err := os.Stat(path)
if err != nil {
return false, err
}

return fileInfo.IsDir(), err
}

func UnmarshallList(arg string) ([]string, error) {
var res []string
// If argument is empty, return an empty list early,
Expand Down