Skip to content

Commit 471d6b2

Browse files
author
coolrc136
committed
🎨 用fmt代替内建print
The print built-in function formats its arguments in an implementation-specific way and writes the result to standard error. Print is useful for bootstrapping and debugging; it is not guaranteed to stay in the language.
1 parent 7409655 commit 471d6b2

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

pkg/lmap/check_ip.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ func CheckIP(subnet string, isVerbose bool) {
4040
hosts[index].isUsed = Ping(hosts[index].host)
4141
if isVerbose {
4242
if hosts[index].isUsed {
43-
println("已使用IP:", hosts[index].host.String())
43+
fmt.Println("已使用IP:", hosts[index].host.String())
4444
} else {
45-
println("未使用IP:", hosts[index].host.String())
45+
fmt.Println("未使用IP:", hosts[index].host.String())
4646
}
4747
}
4848
}(index)
@@ -60,8 +60,8 @@ func printIPList(hosts []HostInfo, boolFilter bool) {
6060

6161
position := 1
6262

63-
for _,hostInfo :=range hosts{
64-
if boolFilter==hostInfo.isUsed {
63+
for _, hostInfo := range hosts {
64+
if boolFilter == hostInfo.isUsed {
6565
fmt.Print(hostInfo.host.String())
6666
if position%OUTPUT_IP_PER_LINE == 0 {
6767
fmt.Println()
@@ -71,5 +71,5 @@ func printIPList(hosts []HostInfo, boolFilter bool) {
7171
position++
7272
}
7373
}
74-
fmt.Println("")
74+
fmt.Println()
7575
}

pkg/lmap/ping.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ func Ping(ip net.IP) bool {
3535
var buffer bytes.Buffer
3636

3737
//先在buffer中写入icmp数据报求去校验和
38-
binary.Write(&buffer, binary.BigEndian, icmp)
38+
_ = binary.Write(&buffer, binary.BigEndian, icmp)
3939
icmp.Checksum = checkSum(buffer.Bytes())
4040
//然后清空buffer并把求完校验和的icmp数据报写入其中准备发送
4141
buffer.Reset()
42-
binary.Write(&buffer, binary.BigEndian, icmp)
42+
_ = binary.Write(&buffer, binary.BigEndian, icmp)
4343

4444
conn, err := net.DialTimeout("ip4:icmp", ip.String(), 1*time.Second)
4545
if err != nil {
@@ -50,21 +50,21 @@ func Ping(ip net.IP) bool {
5050
log.Println("conn.Write error:", err)
5151
return false
5252
}
53-
conn.SetReadDeadline(time.Now().Add(time.Second * 2))
53+
_ = conn.SetReadDeadline(time.Now().Add(time.Second * 2))
5454
num, err := conn.Read(recvBuf)
5555
if err != nil {
5656
return false
5757
}
5858

59-
conn.SetReadDeadline(time.Time{})
59+
_ = conn.SetReadDeadline(time.Time{})
6060

6161
return string(recvBuf[0:num]) != ""
6262
}
6363

6464
func checkSum(data []byte) uint16 {
6565
var (
6666
sum uint32
67-
length int = len(data)
67+
length = len(data)
6868
index int
6969
)
7070
for length > 1 {
@@ -75,7 +75,7 @@ func checkSum(data []byte) uint16 {
7575
if length > 0 {
7676
sum += uint32(data[index])
7777
}
78-
sum += (sum >> 16)
78+
sum += sum >> 16
7979

8080
return uint16(^sum)
8181
}

0 commit comments

Comments
 (0)