refactor #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "oddlid/sensebot-go:refactor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Here I've done some of the things I mentioned. I've mixed styles a bit, like some places (getInput) I check even fmt.F*f for errors, while other places I don't, so you can see what you prefer.
This first draft is just to see if you like this way of doing it, and to agree on a way forward.
Closes #7
@ -0,0 +60,4 @@resp, err := mxClient.Login(ctx,&mautrix.ReqLogin{Type: "m.login.password", // TODO: make constants for all JSON keys used?Actually I think
mautrix.AuthTypePasswordalready existsit does!
@ -0,0 +135,4 @@content: make([]byte, len(prompt)),}res, err := login(context.TODO(), &in, &out)context.TODO()instead oft.Context()?Ah, nice! It's so "new" in Go that I wasn't aware of it. Sure will change!
Oh huh, it was added in Go 1.24, i didn't even realise it was that new 😅
Last I worked with Golang (1.5y ago), we were still on 1.21, so that's why it was "new" to me :P
@ -0,0 +129,4 @@log.Warn().Msg("Received shutdown signal")log.Info().Msg("Waiting for tasks to finish...")wg.Wait()this
wg.Wait()has haunted me since it was added, since I didn't understand contexts at the time and I'm pretty sure has been the source of deadlocks during shutdown before. Up to you if you want to investigate the sanity of it in this PR, but if not I'll probably see if I can yank it later.I haven't actually run this yet, I've just changed stuff to a pattern I know usually works well. Since there's now only one top level context getting passed around, which will get cancelled on the given signals, this should work. But sure, it needs to be properly tested.
0a39c8fa89ee1a65d3acWIP: refactorto refactor