Empty slice literal of type "[]*fly.File" used to define "machineFiles"
256// FilesFromCommand checks the specified flags for files and returns a list of fly.File to be used
257// in the machine configuration.
258func FilesFromCommand(ctx context.Context) ([]*fly.File, error) {
259 machineFiles := []*fly.File{}260
261 localFiles, err := parseFiles(ctx, "file-local", func(value string, file *fly.File) error {
262 content, err := os.ReadFile(value)
Description
An empty slice can be represented by nil
or an empty slice literal. They are
functionally equivalent — their len
and cap
are both zero — but the nil
slice is the preferred style. For more information about empty slices,
see Declaring Empty Slices.
Bad practice
package main
func foo() {
a := []int{}
}
Recommended
package main
func foo() {
var a []int
}