registry: make CreateUnit() explicitly return error
: When marshal() returns a non-nil error 'err', which shadows the pre-defined 'err', we should explicitly return the second error returned from marshal(). Otherwise it will always return nil. To fix other potential errors, let's just return err explicitly. This was discovered by running "go tool vet":
$ go tool vet --shadow ./registry
registry/job.go:316: declaration of "err" shadows declaration at registry/job.go:315
fleetctl: fix wrong error value from matchLocalFileAndUnit()
: In matchLocalFileAndUnit(), if os.Stat() returns nil and getUnitFromFile() returns non-nil error, then in the end matchLocalFileAndUnit() will return (false, nil). That's not the expected result. It should have returned the second error that came from getUnitFromFile(). To avoid further potential bugs, let's follow the idiomatic coding style: first check "err != nil", and fail-fast. This issue was discovered by running "go tool vet".
CreateUnit()
explicitly return error: When
marshal()
returns a non-nil error'err'
, which shadows the pre-defined'err'
, we should explicitly return the second error returned frommarshal()
. Otherwise it will always returnnil
. To fix other potential errors, let's just returnerr
explicitly. This was discovered by running "go tool vet":matchLocalFileAndUnit()
: In
matchLocalFileAndUnit()
, ifos.Stat()
returns nil andgetUnitFromFile()
returns non-nil error, then in the endmatchLocalFileAndUnit()
will return(false, nil)
. That's not the expected result. It should have returned the second error that came fromgetUnitFromFile()
. To avoid further potential bugs, let's follow the idiomatic coding style: first check "err != nil", and fail-fast. This issue was discovered by running "go tool vet".