88package main
99
1010import (
11+ "errors"
1112 "fmt"
1213 "os"
1314 "strings"
1415
15- "github.com/hashicorp/go-multierror"
1616 "github.com/magefile/mage/mg"
1717 "github.com/magefile/mage/sh"
1818)
@@ -118,7 +118,7 @@ func (Format) All() {
118118// License applies the right license header.
119119func (Format ) License () error {
120120 mg .Deps (Prepare .InstallGoLicenser )
121- return combineErr (
121+ return errors . Join (
122122 sh .RunV ("go-licenser" , "-license" , "Elastic" ),
123123 sh .RunV ("go-licenser" , "-license" , "Elastic" , "-ext" , ".proto" ),
124124 )
@@ -137,25 +137,26 @@ func (Check) GoLint() error {
137137 return err
138138 }
139139
140+ var errs []error
140141 packages := strings .Split (packagesString , "\n " )
141142 for _ , pkg := range packages {
142143 if strings .Contains (pkg , "/vendor/" ) {
143144 continue
144145 }
145146
146147 if e := sh .RunV ("golint" , "-set_exit_status" , pkg ); e != nil {
147- err = multierror . Append ( err , e )
148+ errs = append ( errs , e )
148149 }
149150 }
150151
151- return err
152+ return errors . Join ( errs ... )
152153}
153154
154155// License makes sure that all the Golang files have the appropriate license header.
155156func (Check ) License () error {
156157 mg .Deps (Prepare .InstallGoLicenser )
157158 // exclude copied files until we come up with a better option
158- return combineErr (
159+ return errors . Join (
159160 sh .RunV ("go-licenser" , "-d" , "-license" , "Elastic" ),
160161 )
161162}
@@ -171,14 +172,3 @@ func GoInstall(link string) error {
171172 _ , err := sh .Exec (map [string ]string {}, os .Stdout , os .Stderr , "go" , "install" , link )
172173 return err
173174}
174-
175- func combineErr (errors ... error ) error {
176- var e error
177- for _ , err := range errors {
178- if err == nil {
179- continue
180- }
181- e = multierror .Append (e , err )
182- }
183- return e
184- }
0 commit comments