chemtech
@chemtech
Линуксойд, DevOps

Почему выдает предупреждение error strings should not be capitalized or end with punctuation or a newline?

Почему выдает предупреждение error strings should not be capitalized or end with punctuation or a newline?
Вот код:
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()
}


Вот скриншот ошибки
5d25da7ebf8d3550227848.png

5d25da84d044a869754067.png

Пример взял отсюда
https://stackoverflow.com/questions/23529663/how-t...
  • Вопрос задан
  • 3042 просмотра
Пригласить эксперта
Ответы на вопрос 1
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.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы