Skip to content

goroutines.go won't build #37

@mark-summerfield

Description

@mark-summerfield

On both Ubuntu 22.04 and Debian 11 running Go 1.19 from the binary installer, the goroutines.go fails to build:

# gtk-examples/goroutines
./goroutines.go:70:14: assignment mismatch: 2 variables but glib.IdleAdd returns 1 value
./goroutines.go:70:45: too many arguments in call to glib.IdleAdd
	have (func(label *gtk.Label, text string) bool, *gtk.Label, string)
	want (interface{})
./goroutines.go:76:13: assignment mismatch: 2 variables but glib.IdleAdd returns 1 value
./goroutines.go:76:47: too many arguments in call to glib.IdleAdd
	have (func(str string), string)
	want (interface{})

If fixed this by changing the anonymous goroutine as follows:

	go func() {
		for {
			time.Sleep(time.Second)
			s := fmt.Sprintf("Set a label %d time(s)!", nSets)
			handle := glib.IdleAdd(func() bool {
				return LabelSetTextIdle(topLabel, s)
			})
			log.Printf("IdleAdd() #1 handle=%T %v\n", handle, handle)
			nSets++
			s = fmt.Sprintf("Set a label %d time(s)!", nSets)
			handle = glib.IdleAdd(func() bool {
				bottomLabel.SetText(s)
				return false
			})
			log.Printf("IdleAdd() #2 handle=%T %v\n", handle, handle)
			nSets++
		}
	}()

The returned value is a "SourceHandle"; I don't know that that is or means since I'm only just starting with Go/Gtk.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions