From d9c8c5f499ffe1e47988dba05b61a26c3a33c919 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 30 Dec 2016 12:41:59 -0200 Subject: [PATCH] golint --- config/config.go | 11 ++++++++--- config/config_test.go | 3 ++- config/git/log.go | 1 + config/git/tag.go | 2 ++ main.go | 2 +- pipeline/brew/brew.go | 5 ++++- pipeline/build/build.go | 5 ++++- pipeline/compress/zip.go | 5 ++++- pipeline/pipe.go | 6 +++++- pipeline/release/release.go | 5 ++++- split/split.go | 1 + uname/uname.go | 1 + 12 files changed, 37 insertions(+), 10 deletions(-) diff --git a/config/config.go b/config/config.go index d5cd839cd..127f73cac 100644 --- a/config/config.go +++ b/config/config.go @@ -9,36 +9,41 @@ import ( yaml "gopkg.in/yaml.v1" ) -var emptyBrew = HomebrewDeploy{} +var emptyBrew = Homebrew{} -type HomebrewDeploy struct { +// Homebrew contains the brew section +type Homebrew struct { Repo string Token string Caveats string } +// BuildConfig contains the build configuration section type BuildConfig struct { Oses []string Arches []string Main string } +// GitInfo includes tags and diffs used in some point type GitInfo struct { CurrentTag string PreviousTag string Diff string } +// ProjectConfig includes all project configuration type ProjectConfig struct { Repo string BinaryName string `yaml:"binary_name"` Files []string - Brew HomebrewDeploy + Brew Homebrew Token string Build BuildConfig Git GitInfo `yaml:"_"` } +// Load config file func Load(file string) (config ProjectConfig, err error) { data, err := ioutil.ReadFile(file) if err != nil { diff --git a/config/config_test.go b/config/config_test.go index 054ea553f..393fd5c60 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1,8 +1,9 @@ package config import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestFixConfig(t *testing.T) { diff --git a/config/git/log.go b/config/git/log.go index 3c561c46c..0b4d73285 100644 --- a/config/git/log.go +++ b/config/git/log.go @@ -2,6 +2,7 @@ package git import "os/exec" +// Log between two tags func Log(previous, current string) (str string, err error) { cmd := exec.Command( "git", diff --git a/config/git/tag.go b/config/git/tag.go index a061e0402..4c26246b6 100644 --- a/config/git/tag.go +++ b/config/git/tag.go @@ -6,10 +6,12 @@ import ( "strings" ) +// CurrentTag tag being built func CurrentTag() (tag string, err error) { return getTag("") } +// PreviousTag previous tag of the base tag func PreviousTag(base string) (tag string, err error) { return getTag(base + "^") } diff --git a/main.go b/main.go index 12732c9e8..e43954750 100644 --- a/main.go +++ b/main.go @@ -25,7 +25,7 @@ func main() { brew.Pipe{}, } for _, pipe := range pipeline { - if err := pipe.Work(config); err != nil { + if err := pipe.Run(config); err != nil { log.Fatalln(pipe.Name(), "failed:", err.Error()) } } diff --git a/pipeline/brew/brew.go b/pipeline/brew/brew.go index a28154b04..e587eec26 100644 --- a/pipeline/brew/brew.go +++ b/pipeline/brew/brew.go @@ -36,13 +36,16 @@ type templateData struct { Name, Desc, Homepage, Repo, Tag, BinaryName, Caveats string } +// Pipe for brew deployment type Pipe struct{} +// Name of the pipe func (Pipe) Name() string { return "Homebrew" } -func (Pipe) Work(config config.ProjectConfig) error { +// Run the pipe +func (Pipe) Run(config config.ProjectConfig) error { if config.Brew.Repo == "" { return nil } diff --git a/pipeline/build/build.go b/pipeline/build/build.go index 9fe8b42b0..8ff989c1b 100644 --- a/pipeline/build/build.go +++ b/pipeline/build/build.go @@ -12,13 +12,16 @@ import ( "golang.org/x/sync/errgroup" ) +// Pipe for build type Pipe struct{} +// Name of the pipe func (Pipe) Name() string { return "Build" } -func (Pipe) Work(config config.ProjectConfig) error { +// Run the pipe +func (Pipe) Run(config config.ProjectConfig) error { var g errgroup.Group for _, system := range config.Build.Oses { for _, arch := range config.Build.Arches { diff --git a/pipeline/compress/zip.go b/pipeline/compress/zip.go index ec62d55ea..16deaf5c2 100644 --- a/pipeline/compress/zip.go +++ b/pipeline/compress/zip.go @@ -12,13 +12,16 @@ import ( "golang.org/x/sync/errgroup" ) +// Pipe for compress type Pipe struct{} +// Name of the pipe func (Pipe) Name() string { return "Compress" } -func (Pipe) Work(config config.ProjectConfig) error { +// Run the pipe +func (Pipe) Run(config config.ProjectConfig) error { var g errgroup.Group for _, system := range config.Build.Oses { for _, arch := range config.Build.Arches { diff --git a/pipeline/pipe.go b/pipeline/pipe.go index 41fc6c747..c6f7a0058 100644 --- a/pipeline/pipe.go +++ b/pipeline/pipe.go @@ -2,7 +2,11 @@ package pipeline import "github.com/goreleaser/releaser/config" +// Pipe interface type Pipe interface { + // Name of the pipe Name() string - Work(config config.ProjectConfig) error + + // Run the pipe + Run(config config.ProjectConfig) error } diff --git a/pipeline/release/release.go b/pipeline/release/release.go index 8db33c341..4c1d3f348 100644 --- a/pipeline/release/release.go +++ b/pipeline/release/release.go @@ -14,13 +14,16 @@ import ( "golang.org/x/sync/errgroup" ) +// Pipe for github release type Pipe struct{} +// Name of the pipe func (Pipe) Name() string { return "GithubRelease" } -func (Pipe) Work(config config.ProjectConfig) error { +// Run the pipe +func (Pipe) Run(config config.ProjectConfig) error { log.Println("Creating release", config.Git.CurrentTag, "on", config.Repo, "...") ts := oauth2.StaticTokenSource( &oauth2.Token{AccessToken: config.Token}, diff --git a/split/split.go b/split/split.go index 69edcfcb4..c5338e4f9 100644 --- a/split/split.go +++ b/split/split.go @@ -2,6 +2,7 @@ package split import "strings" +// OnSlash split a string on / and return the first 2 parts func OnSlash(pair string) (string, string) { parts := strings.Split(pair, "/") return parts[0], parts[1] diff --git a/uname/uname.go b/uname/uname.go index 4e090e447..bc2a47c54 100644 --- a/uname/uname.go +++ b/uname/uname.go @@ -10,6 +10,7 @@ var mapping = map[string]string{ "amd64": "x86_64", } +// FromGo translates GOOS and GOARCH to uname compatibles func FromGo(s string) string { result := mapping[s] if result == "" {