Small if err cleaning
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
parent
f023195a1e
commit
2026dbd41d
5 changed files with 5 additions and 10 deletions
|
@ -65,8 +65,7 @@ import (
|
||||||
func (mj *JSONLog) MarshalJSON() ([]byte, error) {
|
func (mj *JSONLog) MarshalJSON() ([]byte, error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
buf.Grow(1024)
|
buf.Grow(1024)
|
||||||
err := mj.MarshalJSONBuf(&buf)
|
if err := mj.MarshalJSONBuf(&buf); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return buf.Bytes(), nil
|
return buf.Bytes(), nil
|
||||||
|
|
|
@ -486,8 +486,7 @@ func (f *FlagSet) Set(name, value string) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("no such flag -%v", name)
|
return fmt.Errorf("no such flag -%v", name)
|
||||||
}
|
}
|
||||||
err := flag.Value.Set(value)
|
if err := flag.Value.Set(value); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if f.actual == nil {
|
if f.actual == nil {
|
||||||
|
|
|
@ -12,8 +12,7 @@ import (
|
||||||
// Throws an error if the file does not exist
|
// Throws an error if the file does not exist
|
||||||
func Lstat(path string) (*Stat_t, error) {
|
func Lstat(path string) (*Stat_t, error) {
|
||||||
s := &syscall.Stat_t{}
|
s := &syscall.Stat_t{}
|
||||||
err := syscall.Lstat(path, s)
|
if err := syscall.Lstat(path, s); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return fromStatT(s)
|
return fromStatT(s)
|
||||||
|
|
|
@ -20,8 +20,7 @@ func fromStatT(s *syscall.Stat_t) (*Stat_t, error) {
|
||||||
// Throws an error if the file does not exist
|
// Throws an error if the file does not exist
|
||||||
func Stat(path string) (*Stat_t, error) {
|
func Stat(path string) (*Stat_t, error) {
|
||||||
s := &syscall.Stat_t{}
|
s := &syscall.Stat_t{}
|
||||||
err := syscall.Stat(path, s)
|
if err := syscall.Stat(path, s); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return fromStatT(s)
|
return fromStatT(s)
|
||||||
|
|
|
@ -17,8 +17,7 @@ type conn struct {
|
||||||
|
|
||||||
func (c *conn) Read(b []byte) (int, error) {
|
func (c *conn) Read(b []byte) (int, error) {
|
||||||
if c.timeout > 0 {
|
if c.timeout > 0 {
|
||||||
err := c.Conn.SetReadDeadline(time.Now().Add(c.timeout))
|
if err := c.Conn.SetReadDeadline(time.Now().Add(c.timeout)); err != nil {
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue