See my code attached! My issue is that, after writing to the clipboard, I can only read the string I wrote back during the period I "sleep" after the write.
If I do not sleep, the clipboard immediately reverts to "empty". Am I doing something wrong here? TIA Arie -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/a6325fba-098e-4e42-ac4e-003d270fc3a0n%40googlegroups.com.
package main import ( "fmt" "time" "golang.design/x/clipboard" ) var users = map[string]string{ "u1": "elephant", "u2": "tiger", } func main() { user := users["u1"] fmt.Printf("Users..........: %v\n", users) fmt.Printf("Selected User..: %s\n", user) err := clipboard.Init() if err != nil { panic(err) } clipboard.Write(clipboard.FmtText, []byte(user)) // While sleeping, I can paste the clipboard content ("elephant¨) // in a separate running text editor. // But, when this program is finished, the clipboard appears to be // empty! Why is that? time.Sleep(10 * time.Second) fmt.Println("Ready!") }