mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-02 22:50:18 +00:00
all: replace empty slice literal with var
(#8990)
refactor: replace empty slice literal with `var` 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](https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices). Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
This commit is contained in:
parent
f23c41221b
commit
21c074cc2c
@ -1709,7 +1709,8 @@ func TestGlobalDirectoryTree(t *testing.T) {
|
||||
|
||||
b := func(isfile bool, path ...string) protocol.FileInfo {
|
||||
typ := protocol.FileInfoTypeDirectory
|
||||
blocks := []protocol.BlockInfo{}
|
||||
var blocks []protocol.BlockInfo
|
||||
|
||||
if isfile {
|
||||
typ = protocol.FileInfoTypeFile
|
||||
blocks = []protocol.BlockInfo{{Offset: 0x0, Size: 0xa, Hash: []uint8{0x2f, 0x72, 0xcc, 0x11, 0xa6, 0xfc, 0xd0, 0x27, 0x1e, 0xce, 0xf8, 0xc6, 0x10, 0x56, 0xee, 0x1e, 0xb1, 0x24, 0x3b, 0xe3, 0x80, 0x5b, 0xf9, 0xa9, 0xdf, 0x98, 0xf9, 0x2f, 0x76, 0x36, 0xb0, 0x5c}}}
|
||||
|
@ -15,7 +15,8 @@ func GetLans() ([]*net.IPNet, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
addrs := []net.Addr{}
|
||||
var addrs []net.Addr
|
||||
|
||||
for _, currentIf := range ifs {
|
||||
if currentIf.Flags&net.FlagUp != net.FlagUp {
|
||||
continue
|
||||
|
@ -32,7 +32,8 @@ func (t emptyDirTracker) addFile(path string) {
|
||||
}
|
||||
|
||||
func (t emptyDirTracker) emptyDirs() []string {
|
||||
empty := []string{}
|
||||
var empty []string
|
||||
|
||||
for dir := range t {
|
||||
empty = append(empty, dir)
|
||||
}
|
||||
|
@ -90,7 +90,8 @@ func (v external) Archive(filePath string) error {
|
||||
cmd := exec.Command(words[0], words[1:]...)
|
||||
env := os.Environ()
|
||||
// filter STGUIAUTH and STGUIAPIKEY from environment variables
|
||||
filteredEnv := []string{}
|
||||
var filteredEnv []string
|
||||
|
||||
for _, x := range env {
|
||||
if !strings.HasPrefix(x, "STGUIAUTH=") && !strings.HasPrefix(x, "STGUIAPIKEY=") {
|
||||
filteredEnv = append(filteredEnv, x)
|
||||
|
Loading…
Reference in New Issue
Block a user