mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 17:26:28 +00:00
Prefer nil empty slices
Signed-off-by: David Gageot <david.gageot@docker.com>
This commit is contained in:
parent
ebb5ded10b
commit
810c3e788f
@ -80,7 +80,7 @@ func mkdir(path string, perm os.FileMode) {
|
||||
|
||||
// list of all enabled cgroups
|
||||
func cgroupList() []string {
|
||||
list := []string{}
|
||||
var list []string
|
||||
f, err := os.Open("/proc/cgroups")
|
||||
if err != nil {
|
||||
log.Printf("cannot open /proc/cgroups: %v", err)
|
||||
@ -125,7 +125,7 @@ func read(path string) string {
|
||||
|
||||
// read a directory
|
||||
func readdir(path string) []string {
|
||||
names := []string{}
|
||||
var names []string
|
||||
files, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
log.Printf("cannot read directory %s: %v", path, err)
|
||||
|
@ -85,7 +85,7 @@ func systemInitCmd(ctx context.Context, args []string) {
|
||||
_ = os.Remove(*sock)
|
||||
|
||||
// look for containerd options
|
||||
ctrdArgs := []string{}
|
||||
var ctrdArgs []string
|
||||
var (
|
||||
stderr io.Writer = os.Stderr
|
||||
stdout io.Writer = os.Stdout
|
||||
|
@ -48,7 +48,7 @@ func ListCDROMs() []Provider {
|
||||
cdroms = append(cidevs, cdroms...)
|
||||
cdroms = uniqueString(cdroms)
|
||||
log.Debugf("unique devices to be checked: %v", cdroms)
|
||||
providers := []Provider{}
|
||||
var providers []Provider
|
||||
for _, device := range cdroms {
|
||||
providers = append(providers, NewCDROM(device))
|
||||
}
|
||||
@ -65,7 +65,7 @@ func FindCIs() []string {
|
||||
// Glob can only error on invalid pattern
|
||||
panic(fmt.Sprintf("Invalid glob pattern: %s", blockDevs))
|
||||
}
|
||||
foundDevices := []string{}
|
||||
var foundDevices []string
|
||||
for _, device := range devs {
|
||||
// get the base device name
|
||||
dev := filepath.Base(device)
|
||||
|
@ -197,7 +197,7 @@ func makeDevLinks() error {
|
||||
|
||||
// return a list of all available drives
|
||||
func findDrives() []string {
|
||||
driveKeys := []string{}
|
||||
var driveKeys []string
|
||||
ignoreExp := regexp.MustCompile(`^loop.*$|^nbd.*$|^[a-z]+[0-9]+$`)
|
||||
devs, _ := ioutil.ReadDir("/dev")
|
||||
for _, d := range devs {
|
||||
|
Loading…
Reference in New Issue
Block a user