♻️ Refactor Go to err != nil, err == nil (#12385)

This commit is contained in:
Oleksandr Redko 2024-09-04 04:40:50 +03:00 committed by GitHub
parent 473a159ef2
commit b100721fee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
147 changed files with 1661 additions and 1659 deletions

View file

@ -63,19 +63,19 @@ func loadFonts(currentLanguage string) (ret []*Font) {
for _, fontPath := range findfont.List() {
if strings.HasSuffix(strings.ToLower(fontPath), ".ttc") {
data, err := os.ReadFile(fontPath)
if nil != err {
if err != nil {
logging.LogErrorf("read font file [%s] failed: %s", fontPath, err)
continue
}
collection, err := ttc.ParseCollection(data)
if nil != err {
if err != nil {
//LogErrorf("parse font collection [%s] failed: %s", fontPath, err)
continue
}
for i := 0; i < collection.NumFonts(); i++ {
font, err := collection.Font(i)
if nil != err {
if err != nil {
//LogErrorf("get font [%s] failed: %s", fontPath, err)
continue
}
@ -86,18 +86,18 @@ func loadFonts(currentLanguage string) (ret []*Font) {
}
} else if strings.HasSuffix(strings.ToLower(fontPath), ".otf") || strings.HasSuffix(strings.ToLower(fontPath), ".ttf") {
fontFile, err := os.Open(fontPath)
if nil != err {
if err != nil {
//LogErrorf("open font file [%s] failed: %s", fontPath, err)
continue
}
font, err := sfnt.Parse(fontFile)
if nil != err {
if err != nil {
//LogErrorf("parse font [%s] failed: %s", fontPath, err)
continue
}
t, err := font.NameTable()
if nil != err {
if err != nil {
//LogErrorf("parse font name table [%s] failed: %s", fontPath, err)
return
}
@ -110,7 +110,7 @@ func loadFonts(currentLanguage string) (ret []*Font) {
if sfnt.PlatformLanguageID(1033) == e.LanguageID {
v, _, err := transform.Bytes(textUnicode.UTF16(textUnicode.BigEndian, textUnicode.IgnoreBOM).NewDecoder(), e.Value)
if nil != err {
if err != nil {
//LogErrorf("decode font family [%s] failed: %s", fontPath, err)
continue
}
@ -127,7 +127,7 @@ func loadFonts(currentLanguage string) (ret []*Font) {
}
v, _, err := transform.Bytes(textUnicode.UTF16(textUnicode.BigEndian, textUnicode.IgnoreBOM).NewDecoder(), e.Value)
if nil != err {
if err != nil {
//LogErrorf("decode font family [%s] failed: %s", fontPath, err)
continue
}