From 87172fe0f40150946f0955503170ee3d1fca5edc Mon Sep 17 00:00:00 2001 From: Eng Zer Jun Date: Sun, 8 Oct 2023 00:01:09 +0800 Subject: [PATCH] chore: remove redundant `len` check From the Go specification [1]: "3. If the map is nil, the number of iterations is 0." `len` returns 0 if the map is nil [2]. Therefore, checking `len(v) > 0` around a loop is unnecessary. [1]: https://go.dev/ref/spec#For_range [2]: https://pkg.go.dev/builtin#len Signed-off-by: Eng Zer Jun --- daemon/daemon.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index 93223eff7..a3fdd8aaf 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -109,10 +109,8 @@ func (l processManager) Start(ctx context.Context, conf config.Config) error { } if conf.Network.Driver == gvproxy.Name { args = append(args, "--gvproxy") - if len(conf.Network.DNSHosts) > 0 { - for host, ip := range conf.Network.DNSHosts { - args = append(args, "--gvproxy-hosts", host+"="+ip) - } + for host, ip := range conf.Network.DNSHosts { + args = append(args, "--gvproxy-hosts", host+"="+ip) } }