Answer the question
In order to leave comments, you need to log in
Why does it give the warning error strings should not be capitalized or end with punctuation or a newline?
Why does it give the warning error strings should not be capitalized or end with punctuation or a newline?
Here is the code:
package main
import (
"fmt"
"net"
)
func localAddresses() {
ifaces, err := net.Interfaces()
if err != nil {
fmt.Print(fmt.Errorf("localddresses: %v", err.Error()))
return
}
for _, i := range ifaces {
addrs, err := i.Addrs()
if err != nil {
fmt.Printf("localaddresses: %v", err.Error()))
continue
}
for _, a := range addrs {
switch v := a.(type) {
case *net.IPAddr:
fmt.Printf("%v : %s (%s)\n", i.Name, v, v.IP.DefaultMask())
case *net.IPNet:
fmt.Printf("%v : %s [%v/%v]\n", i.Name, v, v.IP, v.Mask)
}
}
}
}
func main() {
localAddresses()
}
Answer the question
In order to leave comments, you need to log in
Error Strings
Error strings should not be capitalized (unless beginning with proper nouns or acronyms) or end with punctuation, since they are usually printed following other context . That is, use fmt.Errorf("something bad") not fmt.Errorf("Something bad"), so that log.Printf("Reading %s: %v", filename, err) formats without a spurious capital letter mid -message. This does not apply to logging, which is implicitly line-oriented and not combined inside other messages.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question