Skip to content

Commit

Permalink
Use "any" instead of "interface{}"
Browse files Browse the repository at this point in the history
Code style change. I switched all uses over when we migrated to Go
1.19 as base but a few uses of the old name have slipped through
since then. Change them to "any".
  • Loading branch information
Jacalz committed Dec 22, 2024
1 parent 0afa6a9 commit 3a0c4ef
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions app/app_goxjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ func (a *fyneApp) SendNotification(n *fyne.Notification) {
base64Str := base64.StdEncoding.EncodeToString(icon)
mimeType := http.DetectContentType(icon)
base64Img := fmt.Sprintf("data:%s;base64,%s", mimeType, base64Str)
notification.New(n.Title, map[string]interface{}{
notification.New(n.Title, map[string]any{
"body": n.Content,
"icon": base64Img,
})
fyne.LogError("done show...", nil)
}
if permission.Type() != js.TypeString || permission.String() != "granted" {
// need to request for permission
notification.Call("requestPermission", js.FuncOf(func(this js.Value, args []js.Value) interface{} {
notification.Call("requestPermission", js.FuncOf(func(this js.Value, args []js.Value) any {
if len(args) > 0 && args[0].Type() == js.TypeString && args[0].String() == "granted" {
showNotification()
} else {
Expand All @@ -50,7 +50,7 @@ func (a *fyneApp) SendNotification(n *fyne.Notification) {
}
}

var themeChanged = js.FuncOf(func(this js.Value, args []js.Value) interface{} {
var themeChanged = js.FuncOf(func(this js.Value, args []js.Value) any {
if len(args) > 0 && args[0].Type() == js.TypeObject {
fyne.CurrentApp().Settings().(*settings).setupTheme()
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/fyne/internal/commands/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ type translateOpts struct {
// Create or add to translations file by scanning the given files for translation calls.
// Works with and without existing translations file.
func updateTranslationsFile(file string, files []string, opts *translateOpts) error {
translations := make(map[string]interface{})
translations := make(map[string]any)

f, err := os.Open(file)
if err != nil && !errors.Is(err, os.ErrNotExist) {
Expand Down Expand Up @@ -205,7 +205,7 @@ func writeTranslationsFile(b []byte, file string) error {
}

// Update translations hash by scanning the given files, then parsing and walking the AST
func updateTranslationsHash(m map[string]interface{}, srcs []string, opts *translateOpts) error {
func updateTranslationsHash(m map[string]any, srcs []string, opts *translateOpts) error {
fset := token.NewFileSet()
specs := []*ast.ImportSpec{}

Expand Down Expand Up @@ -287,7 +287,7 @@ type visitor struct {
name string
key string
fallback string
m map[string]interface{}
m map[string]any
}

// Method to walk AST using interface for ast.Walk
Expand Down
12 changes: 6 additions & 6 deletions cmd/fyne/internal/commands/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestUpdateTranslationsFile(t *testing.T) {
t.Fatal(err)
}

translations := make(map[string]interface{})
translations := make(map[string]any)
dec := json.NewDecoder(f)
if err := dec.Decode(&translations); err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -142,7 +142,7 @@ func TestUpdateTranslationsHash(t *testing.T) {
srcpath := filepath.Join(dir, src)

opts := translateOpts{}
translations := make(map[string]interface{})
translations := make(map[string]any)
if err := updateTranslationsHash(translations, []string{srcpath}, &opts); err != nil {
t.Fatal(err)
}
Expand All @@ -169,7 +169,7 @@ func TestTranslationsVisitor(t *testing.T) {
}

opts := translateOpts{}
translations := make(map[string]interface{})
translations := make(map[string]any)
ast.Walk(&visitor{opts: &opts, m: translations}, af)

key := "example"
Expand Down Expand Up @@ -203,7 +203,7 @@ func TestTranslateVisitorCall(t *testing.T) {
}

func TestTranslateVisitorLocalize(t *testing.T) {
translations := make(map[string]interface{})
translations := make(map[string]any)
v := &visitor{
opts: &translateOpts{},
m: translations,
Expand All @@ -223,7 +223,7 @@ func TestTranslateVisitorLocalize(t *testing.T) {
}

func TestTranslateVisitorKey(t *testing.T) {
translations := make(map[string]interface{})
translations := make(map[string]any)
v := &visitor{
opts: &translateOpts{},
m: translations,
Expand All @@ -243,7 +243,7 @@ func TestTranslateVisitorKey(t *testing.T) {
}

func TestTranslateVisitorFallback(t *testing.T) {
translations := make(map[string]interface{})
translations := make(map[string]any)
v := &visitor{
opts: &translateOpts{},
m: translations,
Expand Down
2 changes: 1 addition & 1 deletion internal/painter/font.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ var fontCustomCache = &sync.Map{} // map[string]*FontCacheItem for custom resour

type noopLogger struct{}

func (n noopLogger) Printf(string, ...interface{}) {}
func (n noopLogger) Printf(string, ...any) {}

type dynamicFontMap struct {
faces []*font.Face
Expand Down

0 comments on commit 3a0c4ef

Please sign in to comment.