linting: add to Makefile & do some fixes

This commit is contained in:
Zach Ramsay
2017-09-22 11:42:29 -04:00
parent 2130c329eb
commit d6e03d2368
20 changed files with 82 additions and 51 deletions

View File

@ -10,7 +10,7 @@ type CMap struct {
func NewCMap() *CMap {
return &CMap{
m: make(map[string]interface{}, 0),
m: make(map[string]interface{}),
}
}
@ -48,7 +48,7 @@ func (cm *CMap) Size() int {
func (cm *CMap) Clear() {
cm.l.Lock()
defer cm.l.Unlock()
cm.m = make(map[string]interface{}, 0)
cm.m = make(map[string]interface{})
}
func (cm *CMap) Values() []interface{} {

View File

@ -21,7 +21,7 @@ func (se StackError) Error() string {
// panic wrappers
// A panic resulting from a sanity check means there is a programmer error
// and some gaurantee is not satisfied.
// and some guarantee is not satisfied.
func PanicSanity(v interface{}) {
panic(Fmt("Panicked on a Sanity Check: %v", v))
}

View File

@ -95,7 +95,7 @@ func TestWriteCode(t *testing.T) {
common.WriteCode(w, &marshalFailer{}, code)
wantCode := http.StatusBadRequest
assert.Equal(t, w.Code, wantCode, "#%d", i)
assert.True(t, strings.Contains(string(w.Body.Bytes()), errFooFailed.Error()),
assert.True(t, strings.Contains(w.Body.String(), errFooFailed.Error()),
"#%d: expected %q in the error message", i, errFooFailed)
}
}

View File

@ -8,6 +8,7 @@ import (
"os"
"os/signal"
"strings"
"syscall"
)
var (
@ -17,7 +18,7 @@ var (
func TrapSignal(cb func()) {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
signal.Notify(c, os.Kill)
signal.Notify(c, syscall.SIGTERM)
go func() {
for sig := range c {
fmt.Printf("captured %v, exiting...\n", sig)
@ -83,12 +84,7 @@ func MustReadFile(filePath string) []byte {
}
func WriteFile(filePath string, contents []byte, mode os.FileMode) error {
err := ioutil.WriteFile(filePath, contents, mode)
if err != nil {
return err
}
// fmt.Printf("File written to %v.\n", filePath)
return nil
return ioutil.WriteFile(filePath, contents, mode)
}
func MustWriteFile(filePath string, contents []byte, mode os.FileMode) {

View File

@ -31,10 +31,7 @@ func LeftPadString(s string, totalLength int) string {
func IsHex(s string) bool {
if len(s) > 2 && s[:2] == "0x" {
_, err := hex.DecodeString(s[2:])
if err != nil {
return false
}
return true
return err == nil
}
return false
}