mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-24 10:11:48 +00:00
linting: add to Makefile & do some fixes
This commit is contained in:
@ -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{} {
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
10
common/os.go
10
common/os.go
@ -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) {
|
||||
|
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user