@prologic@twtxt.net see where its used maybe that can help.
https://github.com/sour-is/ev/blob/main/app/peerfinder/http.go#L153
This is an upsert. So I pass a streamID which is like a globally unique id for the object. And then see how the type of the parameter in the function is used to infer the generic type. In the function it will create a new *Info and populate it from the datastore to pass to the function. The func will do its modifications and if it returns a nil error it will commit the changes.
The PA type contract ensures that the type fulfills the Aggregate interface and is a pointer to type at compile time.
@prologic@twtxt.net On the one hand, twtxt has become more popular thanks to Yarn.social. On the other hand, subject and hashtag extensions took away the simplicity of the protocol. For example, it is impossible to understand which conversation (#base32hash) a tweet refers to or to reply to a tweet without going to a yarn.social pod. Compare with re: in this tweet which can be written without using any client at all
one that i think is pretty interesting is building up dependent constraints. see here.. it accepts a type but requires the use of a pointer to type.
https://github.com/sour-is/ev/blob/main/pkg/es/es.go#L315-L325
one that i think is pretty interesting is building up dependent constraints. see here.. it accepts a type but requires the use of a pointer to type.
https://github.com/sour-is/ev/blob/main/pkg/es/es.go#L315-L325
I learned how to make gopls syntax highlight go templates in VSCodium.
By adding the following to my config

i could go from
into 
I learned how to make gopls syntax highlight go templates in VSCodium.
By adding the following to my config

i could go from
into 
Data Point
⌘ Read more
Tutorial: Getting started with generics - The Go Programming Language – Okay @xuu@txt.sour.is I quite like Go’s generics now 🤣 After going through this myself I like the semantics and the syntax. I’m glad they did a lot of work on this to keep it simple to both understand and use (just like the rest of Go) 👌
#GoLang #Generics
ChatGPT is good, but it’s not that good 🤣 I asked it to write a program in Go that performs double ratcheting and well the code is total garbage 😅 – Its only as good as the inputs it was trained on 🤣 #OpenAI #GPT3
Should I sell my PC?
I’m not sure yet what I’m going to do with my desktop computer (ASRock Deskmini A300), which I don’t really use anymore since I got my new laptop. ⌘ Read more
I need to learn how to crash dates that are going nowhere with way too much escalation. That should be fun
What was the first PDA?
It wasn’t the Palm Pilot. Nor the Newton. Let’s keep going back to find the answer… ⌘ Read more
** December adventure **
Over the past couple years I’ve done the advent of code to varying degrees. I thought I was going to do it again this year but decided to try something different. I’ve been calling what came together a“ December Adventure.”
It isn’t anything fancy; throughout December I aim to write a little bit of code everyday. So far I’ve written a bit of apl, bash, elisp, explored a bunch of flavors of scheme, and star … ⌘ Read more
@lyse@lyse.isobeef.org when I take him to work I walk him at the parkinglot when I need a break. and on my way home I walk a km or two, and then around the neighbourhood as needed later. But when I go for long walks during the weekend I can walk anywhere from 10km to 20, then the rest is as needed around the house. so he’s well adjusted to short walks as well as long. today he pulled our kids on snow sleds on the street outside here, was really fun :) it was his first time trying that, and I could barely keep up with him. haha.
I started reading the proposal to introduce operator overloading in Go version 2 that I like to see: https://github.com/golang/go/issues/27605 Now a few hours later I ended up at this gem. Write a program that makes 2+2=5: https://codegolf.stackexchange.com/questions/28786/write-a-program-that-makes-2-2-5 There are some awesone solutions. :-)
$name$ and then dispatch the hashing or checking to its specific format.
Circling back to the IsPreferred method. A hasher can define its own IsPreferred method that will be called to check if the current hash meets the complexity requirements. This is good for updating the password hashes to be more secure over time.
func (p *Passwd) IsPreferred(hash string) bool {
_, algo := p.getAlgo(hash)
if algo != nil && algo == p.d {
// if the algorithm defines its own check for preference.
if ck, ok := algo.(interface{ IsPreferred(string) bool }); ok {
return ck.IsPreferred(hash)
}
return true
}
return false
}
https://github.com/sour-is/go-passwd/blob/main/passwd.go#L62-L74
example: https://github.com/sour-is/go-passwd/blob/main/pkg/argon2/argon2.go#L104-L133
$name$ and then dispatch the hashing or checking to its specific format.
Circling back to the IsPreferred method. A hasher can define its own IsPreferred method that will be called to check if the current hash meets the complexity requirements. This is good for updating the password hashes to be more secure over time.
func (p *Passwd) IsPreferred(hash string) bool {
_, algo := p.getAlgo(hash)
if algo != nil && algo == p.d {
// if the algorithm defines its own check for preference.
if ck, ok := algo.(interface{ IsPreferred(string) bool }); ok {
return ck.IsPreferred(hash)
}
return true
}
return false
}
https://github.com/sour-is/go-passwd/blob/main/passwd.go#L62-L74
example: https://github.com/sour-is/go-passwd/blob/main/pkg/argon2/argon2.go#L104-L133
$name$ and then dispatch the hashing or checking to its specific format.
Hold up now, that example hash doesn’t have a
$prefix!
Well for this there is the option for a hash type to set itself as a fall through if a matching hash doesn’t exist. This is good for legacy password types that don’t follow the convention.
func (p *plainPasswd) ApplyPasswd(passwd *passwd.Passwd) {
passwd.Register("plain", p)
passwd.SetFallthrough(p)
}
https://github.com/sour-is/go-passwd/blob/main/passwd_test.go#L28-L31
$name$ and then dispatch the hashing or checking to its specific format.
Hold up now, that example hash doesn’t have a
$prefix!
Well for this there is the option for a hash type to set itself as a fall through if a matching hash doesn’t exist. This is good for legacy password types that don’t follow the convention.
func (p *plainPasswd) ApplyPasswd(passwd *passwd.Passwd) {
passwd.Register("plain", p)
passwd.SetFallthrough(p)
}
https://github.com/sour-is/go-passwd/blob/main/passwd_test.go#L28-L31
$name$ and then dispatch the hashing or checking to its specific format.
Here is an example of usage:
func Example() {
pass := "my_pass"
hash := "my_pass"
pwd := passwd.New(
&unix.MD5{}, // first is preferred type.
&plainPasswd{},
)
_, err := pwd.Passwd(pass, hash)
if err != nil {
fmt.Println("fail: ", err)
}
// Check if we want to update.
if !pwd.IsPreferred(hash) {
newHash, err := pwd.Passwd(pass, "")
if err != nil {
fmt.Println("fail: ", err)
}
fmt.Println("new hash:", newHash)
}
// Output:
// new hash: $1$81ed91e1131a3a5a50d8a68e8ef85fa0
}
This shows how one would set a preferred hashing type and if the current version of ones password is not the preferred type updates it to enhance the security of the hashed password when someone logs in.
https://github.com/sour-is/go-passwd/blob/main/passwd_test.go#L33-L59
$name$ and then dispatch the hashing or checking to its specific format.
Here is an example of usage:
func Example() {
pass := "my_pass"
hash := "my_pass"
pwd := passwd.New(
&unix.MD5{}, // first is preferred type.
&plainPasswd{},
)
_, err := pwd.Passwd(pass, hash)
if err != nil {
fmt.Println("fail: ", err)
}
// Check if we want to update.
if !pwd.IsPreferred(hash) {
newHash, err := pwd.Passwd(pass, "")
if err != nil {
fmt.Println("fail: ", err)
}
fmt.Println("new hash:", newHash)
}
// Output:
// new hash: $1$81ed91e1131a3a5a50d8a68e8ef85fa0
}
This shows how one would set a preferred hashing type and if the current version of ones password is not the preferred type updates it to enhance the security of the hashed password when someone logs in.
https://github.com/sour-is/go-passwd/blob/main/passwd_test.go#L33-L59
I made a thing. Its a multi password type checker. Using the PHC string format we can identify a password hashing format from the prefix $name$ and then dispatch the hashing or checking to its specific format.
I made a thing. Its a multi password type checker. Using the PHC string format we can identify a password hashing format from the prefix $name$ and then dispatch the hashing or checking to its specific format.
GPT-3 is crazy 🤯
Do you want to read why Go is a great programming language? ⌘ Read more
GPT-3 is crazy 🤯
Do you want to read why Go is a great programming language? ⌘ Read more
JMP: Writing a Chat Client from Scratch
There are a lot of things that go into building a chat system, such as client, server, and protocol. Even for only making a client there are lots of areas of focus, such as user experience, features, and performance. To keep this post a manageable size, we will just be building a client and will use an existing server and protocol (accessing Jabber network services using the XMPP protocol). We’ll make a practical GUI so we can test things, but not spend too much time on p … ⌘ Read more
Well, people should be able to talk, even if it’s the ‘wrong’ topic.
I think the whole ‘covid disinformation’ policy at twitter and others (spotify) is ridiculous.
A banner that pops up telling you to go ‘here’ for latest info is crazy.
People die from all kinds of things, covid is no exception from that, but no other virus has been put on display like this one. And also not even being able to discuss things around it (except for the cemented truth) is not something I like. I’m not a conspiracy theorist or anything like that - but I love discussing things, and when you cannot even do that - then I have a issue with it. So many people got banned for simply discussing or trying to discuss issues around it.
For some people they are just fun. Others can’t handle it. They go nuts. 2022-11-29T19:42:33-06:00 I prefer to spend my time writing code for only a few gopher users. No time for conspiracies.
ahh this is useful https://go.dev/doc/modules/managing-dependencies. the go culture doesn’t typically have large dependency graphs like Ruby or JS.
ahh this is useful https://go.dev/doc/modules/managing-dependencies. the go culture doesn’t typically have large dependency graphs like Ruby or JS.
@prologic@twtxt.net the go get and go mod tidy wont fetch new changes. that’s all a manual affair AFAIK
@prologic@twtxt.net the go get and go mod tidy wont fetch new changes. that’s all a manual affair AFAIK
I’ve started playing with Go today, just understood the basics and still a bit confused about the module and goroutine parts.
I’ll try to make something interesting soon.
another paper which relies on questionnaires for attention span. am i going crazy? how is this a good metric‽
FYI, As I’ll be going camping this weekend with the family, I won’t be able to make our weekly call. You guys are welcome to go ahead and discuss various topics and summarise for others to read up on later 👌
I reworked the current ActivityPub implementation of GoBlog, fixed ActivityPub replies to posts and also added support for reply updates and deletions. Under the hood it’s using the comment system. 🥳 Using the go-ap/activitypub library, working with ActivityPub is much easier (but still more complicated than I wish it would be). ⌘ Read more
@prologic@twtxt.net git worked after upgrade. But I seem to have to reinstall go. I have not done that yet. I will see if I have time to fix that later tonight.
LibreOffice going Blockchain?!
Watch now (16 min) | Seriously. LibreOffice met with Ethereum to talk about this. ⌘ Read more
` `` `
@movq@uninformativ.de yeah.. i rewrote it a few times because i thought there was something breaking.. but was mistaken
though now i am seeing a weird cache corruption.. that seems to come and go.

` `` `
@movq@uninformativ.de yeah.. i rewrote it a few times because i thought there was something breaking.. but was mistaken
though now i am seeing a weird cache corruption.. that seems to come and go.

Tell me you write go like javascript without telling me you write go like javascript:
import "runtime/debug"
var Commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
return setting.Value
}
}
}
return ""
}()
Tell me you write go like javascript without telling me you write go like javascript:
import "runtime/debug"
var Commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
return setting.Value
}
}
}
return ""
}()
@prologic@twtxt.net Alright, there’s some erroneous markdown parsing going on, I reckon. In my original twt I have a code block surrounded by three backticks. The code block itself contains a single backtick. However, at least for rendering, yarnd shows three backticks instead (not sure if my markdown is invalid, though):
The power of GitHub in the palm of your hand
GitHub Mobile helps keep work going while you’re going. Untether yourself from your office. ⌘ Read more
Why I bought a new laptop 💻
I just updated my Hardware Uses page. Recently, I bought a new notebook and today I reset my Surface Go and sent it to a trade-in portal. ⌘ Read more
You’re Going to Hate This ⌘ Read more
i only allow myself to go the hard way. good or bad?
Developing Go Apps With Docker
Develop Go applications with Docker using these containerization steps, best practices, optimization tips, and more. ⌘ Read more
Gajim: Gajim 1.5.3
Gajim 1.5.3 brings back a feature many of you missed: selecting and copying multiple messages. Emoji shortcodes have been improved and cover even more emojis now. Gajim also lets you mark workspaces as read, so you don’t have to go through all conversations. Thank you for all your contributions!
Since we changed the way Gajim displays messages in Gajim 1.4, selecting multiple messages to copy them was not possible anymore. With Gajim 1.5.3 you can now select multiple messag … ⌘ Read more
it uses the queries you define for add/del/set/keys. which corrispond to something like INSERT INTO <table> (key, value) VALUES ($key, $value), DELETE ..., or UPDATE ...
the commands are issued by using the maddycli but not the running maddy daemon.
see https://maddy.email/reference/table/sql_query/
the best way to locate in source is anything that implements the MutableTable interface… https://github.com/foxcpp/maddy/blob/master/framework/module/table.go#L38
it uses the queries you define for add/del/set/keys. which corrispond to something like INSERT INTO <table> (key, value) VALUES ($key, $value), DELETE ..., or UPDATE ...
the commands are issued by using the maddycli but not the running maddy daemon.
see https://maddy.email/reference/table/sql_query/
the best way to locate in source is anything that implements the MutableTable interface… https://github.com/foxcpp/maddy/blob/master/framework/module/table.go#L38
I was inclined to let this go so as not to stir anything up, but after some additional thought I’ve decided to call it out. This twt:
is exactly the kind of ad hominem garbage I came to expect from Twitter™, and I’m disappointed to see it replicated here. Rummaging through someone’s background trying to find a “gotcha” argument to take credibility away from what a person is saying, instead of engaging the ideas directly, is what trolls and bad faith actors do. That’s what the twt above does (falsely, I might add–what’s being claimed is untrue).
If you take issue with something I’ve said, you can mute me, unfollow me, ignore me, use TamperMonkey to turn all my twts into gibberish, engage the ideas directly, etc etc etc. There are plenty of options to make what I said go away. Reading through my links, reading about my organization’s CEO’s background, and trying to use that against me somehow (after misinterpreting it no less)? Besides being unacceptable in a rational discussion, and besides being completely ineffective in stopping me from expressing whatever it is you didn’t like, it’s creepy. Don’t do that.
Release Radar · September 2022 Edition
Hackatoberfest, hackathons, and open source contributions. It’s been a hectic month with so many community pull requests to all kinds of projects. So many in fact that we had to spend hours going through all the submissions for this blog post. We almost didn’t get it out before the end of October. Nevertheless, we are […] ⌘ Read more
2017 interview with Haiku’s full time developer
Watch now (55 min) | In this classic episode of the Lunduke Hour (Feb-6-2017) I got to chat with one of the long time developers of Haiku OS – an Open Source operating system inspired by BeOS. This developer, known as “Waddlesplash” would go on to become the first (and so far, only) full time, paid developer of Haiku. ⌘ Read more
[…] UN framework convention on climate change said: “This does not go far enough, fast enough. This is nowhere near the scale of reductions required to put us on track to 1.5C. National governments must set new goals now and implement them in the next eight years.”
[…] UN framework convention on climate change said: “This does not go far enough, fast enough. This is nowhere near the scale of reductions required to put us on track to 1.5C. National governments must set new goals now and implement them in … ⌘ Read more
@prologic@twtxt.net It’s called “cgod” and it isn’t written in C or Go? I want my money back…
I also like Gopher more than Gemini. The problem Gemini is trying to solve is better solved by just writing static HTML 4.01 pages.
I love parsers in go : https://dev-nonsense.com/posts/incremental-parsing-in-go/
@prologic@twtxt.net, business is slow (I also just got off that hyoo-män illness that is going around named COVID), so that leaves me some free time on my entrepreneurial hands. 😂 I have always lurked every couple of weeks or so. I see yarn has regressed on the UI! 😬😩
📣 NEW: Announcing the new and improved Yarns search engine and crawler! search.twtxt.net – Example search for “Hello World” Enjoy! 🤗 – @darch@neotxt.dk When you have this, this is what we need to work on in terms of improving the UI/UX. As a first step you should probably try to apply the same SimpleCSS to this codebase and go from there. – In the end (didn’t happen yet, time/effort) most of the code here in yarns will get reused directly into yarnd, except that I’ll use the bluge indexer instead.
2045
⌘ Read more
On the go with GitHub Projects on GitHub Mobile (public beta)
Stay connected and up to date on your work with GitHub Projects on GitHub Mobile, now in public beta. ⌘ Read more
Why I Might Go To Prison ⌘ Read more
Another change in my infrastructure setup: I replaced rathole with Chisel. There wasn’t any particular reason, I use it in the same way: It’s making a few services and websites hosted on my home server available on my VPS to publish using Caddy and a static IP. Chisel is just a bit more simple to configure using command line flags. And it’s written in Go. ⌘ Read more
GitHub for Startups is generally available
We’re launching GitHub for Startups to give your startup the tools needed to go from idea to unicorn status on the world’s largest developer platform. ⌘ Read more
Transform your software engineering practices with GitHub Enterprise
Go beyond knowing GitHub as the home of open source and explore how GitHub Enterprise can help you transform your software engineering organization and practices. ⌘ Read more
Everyday Carry
⌘ Read more
@lyse@lyse.isobeef.org Thank you :) always nice to have this view when I go to the office, stand there, vape a bit, enjoy the view and silence before heading in and code all day. :)
GoToSocial seems like a promising alternative to Mastodon. It’s written in Go (👍 in my opinion), lightweight and pretty good documented so far. It’s still “alpha software” but seems to make great progress. In the past, I self hosted a microblog.pub instance and then after some time without any Fediverse profile other than my blog, which has ActivityPub support as well, signed up at Fosstodon to be able to reply to blog comments from the Fediverse. I already set up an instace of GTS, but will probably wait to use it … ⌘ Read more
And that I can silence it without having or go through the full test announcing fire and carbon monox throughout the house.
And that I can silence it without having or go through the full test announcing fire and carbon monox throughout the house.
**Every year, on the 3rd Saturday of September the “Software Freedom Day” is celebrated.
In 🇵🇹 Portugal @ANSOL is going to celebrate with a #SoftwareFreedomDay in Oporto:
https://ansol.org/eventos/2022-09-17-software-freedom-day/**
Every year, on the 3rd Saturday of September the “Software Freedom Day” is celebrated.
In 🇵🇹 Portugal @ANSOL is going to celebrate with a #SoftwareFreedomDay in Oporto:
[ansol.org/eventos/202 … ⌘ Read more
@prologic@twtxt.net Yeah its never going to change but its an option to use UTC
A script for Go dependency updates
I regularly update the dependencies of my blog software, a Go based project. Dependency updates are important because they can contain security fixes or fixes for bugs. ⌘ Read more
started my day by going to the dogpark. had a really nice time. now it’s time to telax and enjoy the weekend.
@prologic@twtxt.net Yeah I don’t know how I am going to know if someone wants to talk with me but I guess for now twtxt works.
@prologic@twtxt.net I don’t know how to code in go or anything really. Not even really know how to do html and css only basic things.
@prologic@twtxt.net I don’t know any other way to host my file at my domain unless I make a sub domain. I am going to ask codeberg if they offer access of logs.
@abucci@anthony.buc.ci Its not better than a Cat5e. I have had two versions of the device. The old ones were only 200Mbps i didn’t have the MAC issue but its like using an old 10baseT. The newer model can support 1Gbps on each port for a total bandwidth of 2Gbps.. i typically would see 400-500Mbps from my Wifi6 router. I am not sure if it was some type of internal timeout or being confused by switching between different wifi access points and seeing the mac on different sides.
Right now I have my wifi connected directly with a cat6e this gets me just under my providers 1.3G downlink. the only thing faster is plugging in directly.
MoCA is a good option, they have 2.5G models in the same price range as the 1G Powerline models BUT, only if you have the coax in wall already.. which puts you in the same spot if you don’t. You are for sure going to have an outlet in every room of the house by code.
@abucci@anthony.buc.ci Its not better than a Cat5e. I have had two versions of the device. The old ones were only 200Mbps i didn’t have the MAC issue but its like using an old 10baseT. The newer model can support 1Gbps on each port for a total bandwidth of 2Gbps.. i typically would see 400-500Mbps from my Wifi6 router. I am not sure if it was some type of internal timeout or being confused by switching between different wifi access points and seeing the mac on different sides.
Right now I have my wifi connected directly with a cat6e this gets me just under my providers 1.3G downlink. the only thing faster is plugging in directly.
MoCA is a good option, they have 2.5G models in the same price range as the 1G Powerline models BUT, only if you have the coax in wall already.. which puts you in the same spot if you don’t. You are for sure going to have an outlet in every room of the house by code.
**What’s happening? I’m going to see @MightySieben on #Extramuralhas , that’s what’s happening!
#BifeVolta #SiebenLive #Entremuralhas**
What’s happening? I’m going to see @MightySieben on #Extramuralhas , that’s what’s happening!
#BifeVolta #SiebenLive #Entremuralhas
[nitter.net … ⌘ Read more
Erlang Solutions: Implementing Go Fish to Learn Elixir
A walkthrough of how we implemented GoFish as a way of learning Elixir and the concepts of the BEAM and OTP.
In this article, we will outline our initial design and implementation of the card game Go Fish in Elixir using raw processes, and then describe how we were motivated to re-implement the project using the GenServer module instead. The first step is to agree upon the rules of the game, then describe the domain mode … ⌘ Read more
New day at the office, been a nice first week after vacation so far, but weekend is always appreciated!
Not sure what we’re going to do yet - but I’m sure going to enjoy the days off work :)
Public Service Announcement: Fear not, we’re still on patrol and ask you to keep a close eye on your Yarn neighborhood. We got some reports of suspicious activities going on in the background lately.
Progress! so i have moved into working on aggregates. Which are a grouping of events that replayed on an object set the current state of the object. I came up with this little bit of generic wonder.
type PA[T any] interface {
event.Aggregate
*T
}
// Create uses fn to create a new aggregate and store in db.
func Create[A any, T PA[A]](ctx context.Context, es *EventStore, streamID string, fn func(context.Context, T) error) (agg T, err error) {
ctx, span := logz.Span(ctx)
defer span.End()
agg = new(A)
agg.SetStreamID(streamID)
if err = es.Load(ctx, agg); err != nil {
return
}
if err = event.NotExists(agg); err != nil {
return
}
if err = fn(ctx, agg); err != nil {
return
}
var i uint64
if i, err = es.Save(ctx, agg); err != nil {
return
}
span.AddEvent(fmt.Sprint("wrote events = ", i))
return
}
This lets me do something like this:
a, err := es.Create(ctx, r.es, streamID, func(ctx context.Context, agg *domain.SaltyUser) error {
return agg.OnUserRegister(nick, key)
})
I can tell the function the type being modified and returned using the function argument that is passed in. pretty cray cray.
Progress! so i have moved into working on aggregates. Which are a grouping of events that replayed on an object set the current state of the object. I came up with this little bit of generic wonder.
type PA[T any] interface {
event.Aggregate
*T
}
// Create uses fn to create a new aggregate and store in db.
func Create[A any, T PA[A]](ctx context.Context, es *EventStore, streamID string, fn func(context.Context, T) error) (agg T, err error) {
ctx, span := logz.Span(ctx)
defer span.End()
agg = new(A)
agg.SetStreamID(streamID)
if err = es.Load(ctx, agg); err != nil {
return
}
if err = event.NotExists(agg); err != nil {
return
}
if err = fn(ctx, agg); err != nil {
return
}
var i uint64
if i, err = es.Save(ctx, agg); err != nil {
return
}
span.AddEvent(fmt.Sprint("wrote events = ", i))
return
}
This lets me do something like this:
a, err := es.Create(ctx, r.es, streamID, func(ctx context.Context, agg *domain.SaltyUser) error {
return agg.OnUserRegister(nick, key)
})
I can tell the function the type being modified and returned using the function argument that is passed in. pretty cray cray.
Tomorrow I go back to the office after 4 weeks off, going to be rough to get up in the morning :p
With respect to logging.. oh man.. it really depends on the environment you are working in.. development? log everything! and use a jeager open trace for the super gnarly places. So you can see whats going on while building. But, for production? metrics are king. I don’t want to sift through thousands of lines but have a measure that can tell me the health of the service.
With respect to logging.. oh man.. it really depends on the environment you are working in.. development? log everything! and use a jeager open trace for the super gnarly places. So you can see whats going on while building. But, for production? metrics are king. I don’t want to sift through thousands of lines but have a measure that can tell me the health of the service.
@prologic@twtxt.net Error handling especially in Go is very tricky I think. Even though the idea is simple, it’s fairly hard to actually implement and use in a meaningful way in my opinion. All this error wrapping or the lack of it and checking whether some specific error occurred is a mess. errors.As(…) just doesn’t feel natural. errors.Is(…) only just. I mainly avoided it. Yesterday evening I actually researched a bit about that and found this article on errors with Go 1.13. It shed a little bit of light, but I still have a long way to go, I reckon.
We tried several things but haven’t found the holy grail. Currently, we have a mix of different styles, but nothing feels really right. And having plenty of different approaches also doesn’t help, that’s right. I agree, error messages often end up getting wrapped way too much with useless information. We haven’t found a solution yet. We just noticed that it kind of depends on the exact circumstances, sometimes the caller should add more information, sometimes it’s better if the callee already includes what it was supposed to do.
To experiment and get a feel for yesterday’s research results I tried myself on the combined log parser and how to signal three different errors. I’m not happy with it. Any feedback is highly appreciated. The idea is to let the caller check (not implemented yet) whether a specific error occurred. That means I have to define some dedicated errors upfront (ErrInvalidFormat, ErrInvalidStatusCode, ErrInvalidSentBytes) that can be used in the err == ErrInvalidFormat or probably more correct errors.Is(err, ErrInvalidFormat) check at the caller.
All three errors define separate error categories and are created using errors.New(…). But for the invalid status code and invalid sent bytes cases I want to include more detail, the actual invalid number that is. Since these errors are already predefined, I cannot add this dynamic information to them. So I would need to wrap them à la fmt.Errorf("invalid sent bytes '%s': %w", sentBytes, ErrInvalidSentBytes"). Yet, the ErrInvalidSentBytes is wrapped and can be asserted later on using errors.Is(err, ErrInvalidSentBytes), but the big problem is that the message is repeated. I don’t want that!
Having a Python and Java background, exception hierarchies are a well understood concept I’m trying to use here. While typing this long message it occurs to me that this is probably the issue here. Anyways, I thought, I just create a ParseError type, that can hold a custom message and some causing error (one of the three ErrInvalid* above). The custom message is then returned at Error() and the wrapped cause will be matched in Is(…). I then just return a ParseError{fmt.Sprintf("invalid sent bytes '%s'", sentBytes), ErrInvalidSentBytes}, but that looks super weird.
I probably need to scrap the “parent error” ParseError and make all three “suberrors” three dedicated error types implementing Error() string methods where I create a useful error messages. Then the caller probably could just errors.Is(err, InvalidSentBytesError{}). But creating an instance of the InvalidSentBytesError type only to check for such an error category just does feel wrong to me. However, it might be the way to do this. I don’t know. To be tried. Opinions, anyone? Implementing a whole new type is some effort, that I want to avoid.
Alternatively just one ParseError containing an error kind enumeration for InvalidFormat and friends could be used. Also seen that pattern before. But that would then require the much more verbose var parseError ParseError; if errors.As(err, &parseError) && parseError.Kind == InvalidSentBytes { … } or something like that. Far from elegant in my eyes.
I started working on plugins for GoBlog using a Go module I recently discovered: yaegi. It still feels like magic, because Go is typically a compiled language and yaegi makes it dynamic by embedding an interpreter. Is this overkill for GoBlog or does this possibly enable flexibility like WordPress plugins? ⌘ Read more
It seems quite unlikely to me that humans will cease to care about wealth after the singularity (15% maybe?), or that markets will cease to exist after the singularity (30% or sth). so the best investment strategy now for post-singularity scenarios is to invest broadly in the economy. not sure about divesting from AGI companies (bc they accelerate danger) or AI hardware companies (ditto)—they’re going to especially valuable post-singularity.
Chemtrails
⌘ Read more
**R to @mind_booster: “Web 4.0? Ridiculous!”, some will say, buy that hasn’t stopped anyone from keeping the madness going. Hm, that’s right, nowadays web 5.0 is coined already too - it’s “The Telepathic Web” or “The Symbionet Web”, or, I’ll call it “the Metaverse brain chip”.
https://www.timesnownews.com/exclusive/jack-dorsey-web-5-0-how-will-it-work-and-why-it-is-different-article-92209954**
“Web 4.0? Ridiculous!”, some will say, buy that hasn’t stopped anyone from keeping the madness going. Hm, that’s right … ⌘ Read more
❤️ 🎶: Can’t Go by BEN
Proxy Variable
⌘ Read more
me reading planecrash is unstable bc while reading it I become so enthusiastic about reading textbooks that I go off and do that instead
I seem to have way more ideas for things I want to write when I’m out and about than when I’ve got some time to write at the end of the day. I think this has been going on for months with multiple thoughts I’ve had.
Time to go to sleep, hoping I do get any given how how it is here right now…
I enjoy going through status.cafe users and looking at their web pages, so many awesome websites!
Lunduke Journal price going up later this week!
All existing subscription prices will be grandfathered in – lock in your sub price now! ⌘ Read more