issue experienced in typewise logseq interaction

UPDATE: 2025-02-04 wow, i dont know if this is new or if I stumbled upon something thats been sitting in plain site all along, but today, when after entering a part of a logseq node , with either the # or [[]] notation, if subsequently I type q comma and a space, , then no typesense autocorrection occurs! The issue An example that is around undo-ing auto-corrections, when using the Logseq app....

May 24, 2024 · (updated February 4, 2025) · 1 min · 184 words · Michal Piekarczyk

Nice pretty printing go slices

package main import ( "encoding/json" "fmt" ) type Foo struct { Blah int Flarg string } func main() { var stuff []Foo = []Foo{ Foo{Blah: 8, Flarg: "sure"}, Foo{Blah: 7, Flarg: "mhm"}, } stuffBytes, err := json.MarshalIndent(stuff, "", " ") if err != nil { fmt.Println("Marshaling errors", err) return } fmt.Println("harder to read\n", stuff) fmt.Println("\nbetter\n", string(stuffBytes)) } outupt is easy on the eyes harder to read [{8 sure} {7 mhm}] better [ { "Blah": 8, "Flarg": "sure" }, { "Blah": 7, "Flarg": "mhm" } ]

March 30, 2024 · (updated May 26, 2024) · 1 min · 85 words · Michal Piekarczyk

Scope trickiness in Go

Go scope is different for for loops and if blocks than in Python For example, with some code, package main import ( "fmt" "slices" ) func main() { var stuff = []string{ "foo", "bar", "hmm", } if idx := slices.IndexFunc(stuff, func(x string) bool { return x == "foo" }); idx == -1 { fmt.Println("yes") found := true } else { fmt.Println("no") found := false } fmt.Printf("found %v\n", found) } But the error is...

March 30, 2024 · 1 min · 155 words · Michal Piekarczyk

Go Sprinkle reflection on domain driven development

Ok cool, realizing, following on from earlier post, that to nicely test the case when I have a Merchant and I am only making updates to it with UpdateMerchantRequest, I would need a nice generic way to obtain a subset struct instance from the other. Getting ChatGPT to help, here is what I asked, Okay I have a strategy I’m using, where I have a go struct for a merchant that mirrors a postgresql database table and also another struct for updates to it which is a subset,...

February 24, 2024 · 2 min · 326 words · Michal Piekarczyk

Minimizing Golang struct types while observing tyep safety

Asked chat gpt the following conundrum, if I’m using Go struct types to model a data type, matching a table in my postgresql database say, type Merchant struct { id int, created_at time.Time, name string, phone string, email string, } I have the following question, does it make sense that I ended up creating different types also for the HTTP request to create this merchant, type CreateMerchantRequest struct { name string, phone string, email string, } since the id and created_at timestamps are populated automatically, and also another to update the merchant,...

February 4, 2024 · 2 min · 368 words · Michal Piekarczyk