Is there a way to ensure that a goroutine will run only in a specific OS thread? For example, when GUI operations must run in the GUI thread, but there might be multiple goroutines running GUI code.
GOMAXPROCS(1)
does the job technically, but that defeats the purpose of multithreading.
LockOSThread()
works too, but that prevents any other goroutine from running in that thread as well.
Is there a way to do this, or must everything that requires the same thread also run in the same goroutine?