misc: Upgrade Go to v1.21
Upgrade to 1.21 as 1.20 is now unmaintained. Most changes are related to the new `slices` package from standard library, which can replace some existing custom functions.
This commit is contained in:
+5
-5
@@ -4,15 +4,15 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"image/color"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/dweymouth/supersonic/backend"
|
||||
"github.com/dweymouth/supersonic/res"
|
||||
"github.com/dweymouth/supersonic/sharedutil"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
@@ -200,7 +200,7 @@ func (m *MyTheme) Font(style fyne.TextStyle) fyne.Resource {
|
||||
}
|
||||
case fyne.TextStyle{Bold: true}:
|
||||
if m.BoldFont != "" && boldFont == nil {
|
||||
if content, err := ioutil.ReadFile(m.BoldFont); err != nil {
|
||||
if content, err := os.ReadFile(m.BoldFont); err != nil {
|
||||
m.BoldFont = ""
|
||||
} else {
|
||||
normalFont = fyne.NewStaticResource("boldFont", content)
|
||||
@@ -222,7 +222,7 @@ func (m *MyTheme) Size(name fyne.ThemeSizeName) float32 {
|
||||
|
||||
func (m *MyTheme) getVariant() fyne.ThemeVariant {
|
||||
v := DefaultAppearance // default if config has invalid or missing setting
|
||||
if sharedutil.SliceContains(
|
||||
if slices.Contains(
|
||||
[]string{string(AppearanceLight), string(AppearanceDark), string(AppearanceAuto)},
|
||||
m.config.Appearance) {
|
||||
v = AppearanceMode(m.config.Appearance)
|
||||
@@ -242,7 +242,7 @@ func readTTFFile(filepath string) ([]byte, error) {
|
||||
log.Printf("error loading custom font %q: %s", filepath, err.Error())
|
||||
return nil, err
|
||||
}
|
||||
content, err := ioutil.ReadFile(filepath)
|
||||
content, err := os.ReadFile(filepath)
|
||||
if err != nil {
|
||||
log.Printf("error loading custom font %q: %s", filepath, err.Error())
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
"image/color"
|
||||
"io"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"github.com/dweymouth/supersonic/sharedutil"
|
||||
"github.com/pelletier/go-toml/v2"
|
||||
)
|
||||
|
||||
@@ -109,7 +109,7 @@ func DecodeThemeFile(reader io.Reader) (*ThemeFile, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if theme.SupersonicTheme.Name == "" || !sharedutil.SliceContains(validThemeVersions, theme.SupersonicTheme.Version) {
|
||||
if theme.SupersonicTheme.Name == "" || !slices.Contains(validThemeVersions, theme.SupersonicTheme.Version) {
|
||||
return nil, errors.New("invalid theme file name or version")
|
||||
}
|
||||
if !(theme.SupersonicTheme.SupportsDark || theme.SupersonicTheme.SupportsLight) {
|
||||
@@ -129,7 +129,7 @@ func (t *ThemeFile) SupportsVariant(v fyne.ThemeVariant) bool {
|
||||
|
||||
// Parses a CSS-style #RRGGBB or #RRGGBBAA string
|
||||
func ColorStringToColor(colorStr string) (color.Color, error) {
|
||||
if !strings.HasPrefix(colorStr, "#") || !sharedutil.SliceContains([]int{7, 9}, len(colorStr)) {
|
||||
if !strings.HasPrefix(colorStr, "#") || !slices.Contains([]int{7, 9}, len(colorStr)) {
|
||||
return color.Black, errors.New("invalid color string")
|
||||
}
|
||||
colorBytes := make([]byte, 4)
|
||||
|
||||
Reference in New Issue
Block a user