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.
+1
@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.
Scientific Field Prefixes
⌘ Read more
I’m trying to switch from Konversation to irssi. Let’s see how that goes. Any irssiers out there who can recommend specific settings or scripts? I already got myself trackbar.pl
and nickcolor.pl
as super-essentials. Also trying window_switcher.pl
. Somehow my custom binds for Ctrl+1/2/3/etc.
to switch to window 1/2/3/etc. doesn’t do anything: { key = "^1"; id = "change_window"; data = "1"; }
(I cannot use the default with Alt
as this is handled by my window manager). Currently, I’m just cycling with Ctrl+N/P
. Other things to solve in the near future:
- better, more colorful and compact theme (just removed clock from statusbar so far)
- getting bell/urgency hints working on arriving messages
- nicer tabs in status bar, maybe even just channel names and no indexes
- decluster status bar with user and channel modes (I never cared about those in the last decade)
user/bmallred/data/2022-07-15-20-04-40.fit: 1.81 miles, 00:13:51 average pace, 00:25:05 duration
user/bmallred/data/2022-07-05-17-11-30.fit: 1.69 miles, 00:08:47 average pace, 00:14:49 duration
in the [[gameoflife]] there are 8 cells around each cell, that can be 0 or 1. Make #sound with that. #8bit or even #1bit with bitscan. Maybe on #uxn . #halfbaked #coding #cellularautomata
user/bmallred/data/2022-06-16-16-33-12.fit: 1.05 miles, 00:12:06 average pace, 00:12:41 duration
user/bmallred/data/2022-06-08-08-44-20.fit: 1.00 miles, 00:10:37 average pace, 00:10:36 duration
It’ll track a bunch of finger(1) endpoints and let you see what’s new. Very early draft. Not actually a social network, more an anti-social network for ‘80s CompSci transplants. :-)
A read-only, finger(1)-based social network, maybe? http://txtpunk.com/fingers/
user/bmallred/data/2022-05-21-09-57-16.fit: 1.30 miles, 00:33:48 average pace, 00:43:54 duration
user/bmallred/data/2022-05-18-11-10-15.fit: 1.00 miles, 00:10:31 average pace, 00:10:32 duration
Elon Musk Offers To Buy Twitter For $41 Billion
Billionaire Elon Musk has offered to buy Twitter for about $41 billion, just days after rejecting a seat on the social media company’s board. From a report: Musk’s offer price of $54.20 per share, which was disclosedin a regulatory filing on Thursday, represents a 38% premium to Twitter’s April 1 close, the last trading day before the Tesla CEO’s more than 9% stake in the company … ⌘ Read more
maxlenght
?, I found a workaround by writing from Goryon on mobile, on PC i can simply change the limit with the inspector but isn't it there for a reason?
@mckinley@twtxt.net Agreed! 👌
Can we all vote on the new default being 1024
then perhaps? 🤔
+1 from me
@novaburst@twt.nfld.uk I doubt there will ever be a 2.0 … It may end up like java and they strip off the 1.
#!/bin/sh
# Validate environment
if ! command -v msgbus > /dev/null; then
printf "missing msgbus command. Use: go install git.mills.io/prologic/msgbus/cmd/msgbus@latest"
exit 1
fi
if ! command -v salty > /dev/null; then
printf "missing salty command. Use: go install go.mills.io/salty/cmd/salty@latest"
exit 1
fi
if ! command -v salty-keygen > /dev/null; then
printf "missing salty-keygen command. Use: go install go.mills.io/salty/cmd/salty-keygen@latest"
exit 1
fi
if [ -z "$SALTY_IDENTITY" ]; then
export SALTY_IDENTITY="$HOME/.config/salty/$USER.key"
fi
get_user () {
user=$(grep user: "$SALTY_IDENTITY" | awk '{print $3}')
if [ -z "$user" ]; then
user="$USER"
fi
echo "$user"
}
stream () {
if [ -z "$SALTY_IDENTITY" ]; then
echo "SALTY_IDENTITY not set"
exit 2
fi
jq -r '.payload' | base64 -d | salty -i "$SALTY_IDENTITY" -d
}
lookup () {
if [ $# -lt 1 ]; then
printf "Usage: %s nick@domain\n" "$(basename "$0")"
exit 1
fi
user="$1"
nick="$(echo "$user" | awk -F@ '{ print $1 }')"
domain="$(echo "$user" | awk -F@ '{ print $2 }')"
curl -qsSL "https://$domain/.well-known/salty/${nick}.json"
}
readmsgs () {
topic="$1"
if [ -z "$topic" ]; then
topic=$(get_user)
fi
export SALTY_IDENTITY="$HOME/.config/salty/$topic.key"
if [ ! -f "$SALTY_IDENTITY" ]; then
echo "identity file missing for user $topic" >&2
exit 1
fi
msgbus sub "$topic" "$0"
}
sendmsg () {
if [ $# -lt 2 ]; then
printf "Usage: %s nick@domain.tld <message>\n" "$(basename "$0")"
exit 0
fi
if [ -z "$SALTY_IDENTITY" ]; then
echo "SALTY_IDENTITY not set"
exit 2
fi
user="$1"
message="$2"
salty_json="$(mktemp /tmp/salty.XXXXXX)"
lookup "$user" > "$salty_json"
endpoint="$(jq -r '.endpoint' < "$salty_json")"
topic="$(jq -r '.topic' < "$salty_json")"
key="$(jq -r '.key' < "$salty_json")"
rm "$salty_json"
message="[$(date +%FT%TZ)] <$(get_user)> $message"
echo "$message" \
| salty -i "$SALTY_IDENTITY" -r "$key" \
| msgbus -u "$endpoint" pub "$topic"
}
make_user () {
mkdir -p "$HOME/.config/salty"
if [ $# -lt 1 ]; then
user=$USER
else
user=$1
fi
identity_file="$HOME/.config/salty/$user.key"
if [ -f "$identity_file" ]; then
printf "user key exists!"
exit 1
fi
# Check for msgbus env.. probably can make it fallback to looking for a config file?
if [ -z "$MSGBUS_URI" ]; then
printf "missing MSGBUS_URI in environment"
exit 1
fi
salty-keygen -o "$identity_file"
echo "# user: $user" >> "$identity_file"
pubkey=$(grep key: "$identity_file" | awk '{print $4}')
cat <<- EOF
Create this file in your webserver well-known folder. https://hostname.tld/.well-known/salty/$user.json
{
"endpoint": "$MSGBUS_URI",
"topic": "$user",
"key": "$pubkey"
}
EOF
}
# check if streaming
if [ ! -t 1 ]; then
stream
exit 0
fi
# Show Help
if [ $# -lt 1 ]; then
printf "Commands: send read lookup"
exit 0
fi
CMD=$1
shift
case $CMD in
send)
sendmsg "$@"
;;
read)
readmsgs "$@"
;;
lookup)
lookup "$@"
;;
make-user)
make_user "$@"
;;
esac
;-) I seem to remember there being g a script that checks for 1.17. Maybe that is only on make preflight
@prologic@twtxt.net yarn builds in 1.18!
There is no place like home.
Wow. I’m paying about 100 USD for my cable internet. Hard to estimate since its part of a tvd bundle. But it is 1.2Gbit down and 40Mbit up. And speed tests at that on the regular. The new house will have FTTH gigabit for 80ish.
Do they have Starlink beta down there yet?
Only 1 day of activity so far, but I’ve started a new project log for whatever the heck I end up doing to this Monroe 425 I got. http://a.9srv.net/monroe425
Netflix Raises Monthly Subscription Prices in US, Canada
Netflix has raised its monthly subscription price by $1 to $2 per month in the United States depending on the plan, the company said on Friday, to help pay for new programming to compete in the crowded streaming TV market. From a report: The standard plan, which allows for two simultaneous streams, now costs $15.49 per month, up from $13.99, in the Unite … ⌘ Read more
@fastidious@arrakis.netbros.com +1 …Now just a way to come up with the $20 per twt to store the data.
Decorative Constants
⌘ Read more
This pi will now boot directly to ed if the gpio pin is grounded at boot time. ed(1)term v1. :-) http://txtpunk.com/edterm/
@lyse ed(1) is the standard editor. ;-)
I fork bombed my computer! With ed(1)!!! Haven’t done that in a while.
@fastidious@arrakis.netbros.com (#twksmyq) IPv6 because localhost -> ::1 is preferred on linux over ol’ 127.0.0.1
Now this is very useful.. it means when yarn is doing an HTTP request to itself its not closing the connection. that could mean a http.Response Body is not getting closed.
Btw… You guys have gotta start posting more pictures/videos a bit more regularly 😂 Every time I show Yarn.social off to a friend to “sell” them the platform and get them off their privacy eroding garbage Facebook/Twitter/etc) The no. #1 question I get asked is:
Oh is this only comments/text
🤣 Let’s show off the platform as a whole a bit eh? 😅
@darch@twtxt.net
Getting this when trying to use it:
error executing template timeline: template: timeline:131:43: executing "twt" at <formatForDateTime>: wrong number of args for formatForDateTime: want 2 got 1
+1
My nutritional supplements aim should be:
- 1 or 1.5 cups of lentils (or any beans you might like better).
- 2 or 2.5 cups of bitter greens.
- 1 cup of your favourite protein (or an egg), grilled, or fried with a little of olive oil.
- 1 or 2 tomatoes, or a handful if of the cherry type.
- No added sugars. If it is sweet, make it have fibre.
- No added salt (or very little and ionised), as salt is everywhere.
Related, I tried wild rice for the first time yesterday. It was different, in a good way.
Standby BIG-IP F5s upgraded to TMOS 16.1 (LTS). All their pairs (now on standby) will be upgraded on Wednesday. Just giving the TMOS some time to settle down, and feel at home. Hahahaha!
@stigatle@twtxt.net
You can get an Air for $1,000 (or $1,200 with 16GB). I have used it (with 8GB), and that machine flies. I can’t imagine how fast one with an M1MAX will feel.
An estimated 6.8 million fewer female births will be recorded across India by 2030 because of the persistent use of selective abortions, researchers estimate. — The Guardian
And from the same article:
India’s skewed ratio of men to women – currently between 900-930 females per 1,000 males – reflects India’s ingrained attitude towards girls. Boys are seen as breadwinners while girls are seen as a burden across every social class. Boys are more likely to receive more nutritious food and better medical care than girls.
That is just beyond sad.
So, first multi-line test, because I coudn’t wait. 😄
- One line - Two lines - Three lines
And:
- One line 2. Two lines 3. Three lines
How would jenny handle multiline twts? Let’s find out! - One - Two - Three And: 1. One 2. Two 3. Three
a simple Makefile for forwarding internet to your local machine:
SSH_HOST=https://xuu.me
PRIV_KEY=~/.ssh/id_ed25519
forward:
LOCAL_PORT=$(HOST_PORT); sh -c "$(shell http --form POST $(SSH_HOST) pub=@$(PRIV_KEY).pub | grep ^ssh | head -1 | awk '{ print "ssh -T -p " $$4 " " $$5 " -R " $$7 " -i $(PRIV_KEY)" }')"
@niplav@niplav.github.io bigwor~1
@prologic@twtxt.net @jlj@twt.nfld.uk @movq@www.uninformativ.de
/p/tmp > git clone https://www.uninformativ.de/git/lariza.git Mon May 24 23:48:18 2021
Cloning into 'lariza'...
/p/tmp > tree lariza/ 12.5s Mon May 24 23:48:32 2021
lariza/
├── BUGS
├── CHANGES
├── LICENSE
├── Makefile
├── PATCHES
├── README
├── browser.c
├── man1
│ ├── lariza.1
│ └── lariza.usage.1
├── user-scripts
│ └── hints.js
└── we_adblock.c
2 directories, 11 files
I was reading dd(1), where it is mentioned in passing, obliquely. Then stty(1) has more info.
oh don’t mind me, just porting srfi-1 to rc shell
Go 1.16 is released ⌘ Read more…
interesting RFC dated April 1st, 1998: Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0):
looking at the date this was published, i think the authors originally meant this as an apil’s fool joke/prank.
funny because now we have IOTs and this is somewhat a reality today :P
Really looking forward to the release of Go 1.16
lextwt
branch. There's a noticeable ~2x increase in CPU usage across the board since I deployed this at ~16.30pm (AEST).
@prologic@twtxt.net That is strange.. i wonder if there is another change that is causing it. Benchmarks are thinking the other way :|
BenchmarkAll/retwt-16 1 4940172200 ns/op 587319376 B/op 2587159 allocs/op
BenchmarkAll/lextwt-16 1 775764020 ns/op 9223088 B/op 197557 allocs/op
BenchmarkParse/retwt-16 1 591158277 ns/op 67539096 B/op 230841 allocs/op
BenchmarkParse/lextwt-16 1 716961837 ns/op 5450448 B/op 130290 allocs/op
BenchmarkOutput/retwt-html-16 1 8358103017 ns/op 918709168 B/op 4692292 allocs/op
BenchmarkOutput/lextwt-html-16 1 822033267 ns/op 14280112 B/op 261795 allocs/op
BenchmarkOutput/retwt-markdown-16 1 8114225415 ns/op 929928384 B/op 4693004 allocs/op
BenchmarkOutput/lextwt-markdown-16 1 806554306 ns/op 14332608 B/op 270905 allocs/op
BenchmarkOutput/retwt-text-16 1 8098215897 ns/op 923862192 B/op 4684739 allocs/op
BenchmarkOutput/lextwt-text-16 1 745064673 ns/op 12689784 B/op 252476 allocs/op
BenchmarkOutput/retwt-literal-16 1 4068799822 ns/op 409517880 B/op 2372471 allocs/op
BenchmarkOutput/lextwt-literal-16 1 754793627 ns/op 9834520 B/op 214931 allocs/op
Are you able to coax your webserver to add the charset to the content type header? Browsers are having a hard time thinking you are sending latin-1
content-type: text/plain; charset=utf-8