Post ASrjKuDYo5GyBiR9Dk by hj@shigusegubu.club
(DIR) More posts by hj@shigusegubu.club
(DIR) Post #ASrWqk4mkWgKb5BOka by rin@udongein.xyz
2023-02-20T06:28:28.502272Z
5 likes, 1 repeats
trying to make a thing in go to see why people like it, but writing if (err != nil) every 5 lines is making me go insane
(DIR) Post #ASrXtOOXuryKB1Fm08 by indev@udongein.xyz
2023-02-20T06:36:36.127776Z
1 likes, 0 repeats
@rin Yeah, thats same for lua. You have to either use pcall to catch errors or return extra "error" value from function (well, pcall returns result and err too, so in any case you have to write "if not err then"). I wasn't writing lua code with error handling until yesterday, and it is really annoying
(DIR) Post #ASrY4VdFLi7fo8Qk4W by orekix@shitposter.club
2023-02-20T06:43:05.094692Z
0 likes, 0 repeats
@rin what would you rather use?
(DIR) Post #ASrYuombOLXYGGkVOa by nik@misskey.bubbletea.dev
2023-02-20T06:45:38.080Z
3 likes, 0 repeats
@rin@udongein.xyz i personally like it because the tooling is very good + its simplicity allows me to understand other people's code extremely quickly. but then the simplicity is stupid sometimes.
(DIR) Post #ASrbn4mkJMYnRBog1Q by rin@udongein.xyz
2023-02-20T07:23:05.871184Z
1 likes, 0 repeats
@orekix in terms of error handling if go had smth like rust ? operator (unwrap result or propagate error to the caller) and tagged unions (so that you can just write return Err(err) instead of for example return []map[string]interface{}{}, err) it would be much nicer to work with imo.though for what im doing right now (quickly thrown together cli app/daemon that does a bunch of calls to google cloud apis) a scripting language like js would suffice
(DIR) Post #ASrgfpbQrPuU5rtBxI by hakui@tuusin.misono-ya.info
2023-02-20T08:19:27.365262Z
3 likes, 0 repeats
@orekix @rin if ((err.ToString.CompareTo("nil")==0)==false)
(DIR) Post #ASriE4WnyUhCBScFfc by hj@shigusegubu.club
2023-02-20T08:36:23.666099Z
2 likes, 0 repeats
@rin i went insane already when i had to pass return pointer to a function instead of you know, reading function's return.
(DIR) Post #ASrieK5ojCR9zCVgcy by vaartis@pl.kotobank.ch
2023-02-20T08:41:59.178265Z
0 likes, 0 repeats
@hj @rin return through pointer argument, the classic programming idiocy
(DIR) Post #ASrjKuDYo5GyBiR9Dk by hj@shigusegubu.club
2023-02-20T08:48:41.068095Z
2 likes, 0 repeats
@vaartis @rin much like functional programming idiocy of having an infinite loop just to store some state
(DIR) Post #ASrjaNiDQgcC0V9fe4 by vaartis@pl.kotobank.ch
2023-02-20T08:52:28.444026Z
0 likes, 0 repeats
@hj @rin you are indeed correct
(DIR) Post #ASrjpfaBGnTNm6gdjk by hj@shigusegubu.club
2023-02-20T08:54:22.855612Z
1 likes, 0 repeats
@vaartis @rin by allah, all programming languages are cringeexcept javascript, that honest retard is alright
(DIR) Post #ASrk1ca8FiitwXMZ2O by kura@z0ne.social
2023-02-20T08:57:00.719Z
1 likes, 0 repeats
@rin@udongein.xyz that is the cost of not having exception handling.i still like it, that is the only annoying part of it though
(DIR) Post #ASrllElVEaCjLtzr4C by rin@udongein.xyz
2023-02-20T09:12:00.246954Z
2 likes, 0 repeats
@kura you can have nicer error handling without exceptions though. I think the way it's done in rust is pretty nice
(DIR) Post #ASrmRjwFirTSCII99U by kura@z0ne.social
2023-02-20T09:24:08.077Z
0 likes, 0 repeats
@rin@udongein.xyzthere is a way to simulate something similar in go.
(DIR) Post #ASrmvmaiQOCz6zXkjQ by kura@z0ne.social
2023-02-20T09:29:33.970Z
0 likes, 0 repeats
@rin@udongein.xyz package mainfunc must(err error) {if err != nil {panic(err)}}func must2[K any](val K, err error) K {if err != nil {panic(err)}return val}func run() (err error) {defer func(pErr error) {if r := recover(); r != nil { err = r.(error) }}(err)must(functionThatReturnsOnlyError())val := must2(functionThatReturnsValAndError())}rough sketch without testing