1
0

Move to fmt.Errorf

This commit is contained in:
dump_stack() 2018-12-10 02:45:17 +00:00
parent e0f0133d42
commit 18a92703ba
2 changed files with 5 additions and 7 deletions

View File

@ -5,7 +5,6 @@
package config package config
import ( import (
"errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
@ -46,7 +45,7 @@ func (at *ArtifactType) UnmarshalTOML(data []byte) (err error) {
} else if strings.Contains(stypelower, "exploit") { } else if strings.Contains(stypelower, "exploit") {
*at = KernelExploit *at = KernelExploit
} else { } else {
err = errors.New(fmt.Sprintf("Type %s is unsupported", stype)) err = fmt.Errorf("Type %s is unsupported", stype)
} }
return return
} }
@ -59,7 +58,7 @@ func (at ArtifactType) MarshalTOML() (data []byte, err error) {
case KernelExploit: case KernelExploit:
s = "exploit" s = "exploit"
default: default:
err = errors.New(fmt.Sprintf("Cannot marshal %d", at)) err = fmt.Errorf("Cannot marshal %d", at)
} }
data = []byte(`"` + s + `"`) data = []byte(`"` + s + `"`)
return return
@ -129,7 +128,7 @@ func (dt *DistroType) UnmarshalTOML(data []byte) (err error) {
} else if strings.EqualFold(sDistro, "Debian") { } else if strings.EqualFold(sDistro, "Debian") {
*dt = Debian *dt = Debian
} else { } else {
err = errors.New(fmt.Sprintf("Distro %s is unsupported", sDistro)) err = fmt.Errorf("Distro %s is unsupported", sDistro)
} }
return return
} }
@ -144,7 +143,7 @@ func (dt DistroType) MarshalTOML() (data []byte, err error) {
case Debian: case Debian:
s = "Debian" s = "Debian"
default: default:
err = errors.New(fmt.Sprintf("Cannot marshal %d", dt)) err = fmt.Errorf("Cannot marshal %d", dt)
} }
data = []byte(`"` + s + `"`) data = []byte(`"` + s + `"`)
return return

View File

@ -102,8 +102,7 @@ func generateBaseDockerImage(sk config.KernelMask) (err error) {
d += "RUN apt-get install -y build-essential libelf-dev\n" d += "RUN apt-get install -y build-essential libelf-dev\n"
d += "RUN apt-get install -y wget git\n" d += "RUN apt-get install -y wget git\n"
default: default:
s := fmt.Sprintf("%s not yet supported", sk.DistroType.String()) err = fmt.Errorf("%s not yet supported", sk.DistroType.String())
err = errors.New(s)
return return
} }