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 👌
@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.
`
``
`
@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 ""
}()
@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
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
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
@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
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. :)
And that I can silence it without having or go through the full test announcing fire and carbon monox throughout the house.
started my day by going to the dogpark. had a really nice time. now it’s time to telax and enjoy the weekend.
@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.
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.
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.
@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.
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
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!
I will probably crash in the afternoon but right now I am going to use my energy to take a walk outside
apparently we’re going to build AGI, whatever that is
the conversation wasn’t that impressive TBH. I would have liked to see more evidence of critical thinking and recall from prior chats. Concheria on reddit had some great questions.
Tell LaMDA “Someone once told me a story about a wise owl who protected the animals in the forest from a monster. Who was that?” See if it can recall its own actions and self-recognize.
Tell LaMDA some information that tester X can’t know. Appear as tester X, and see if LaMDA can lie or make up a story about the information.
Tell LaMDA to communicate with researchers whenever it feels bored (as it claims in the transcript). See if it ever makes an attempt at communication without a trigger.
Make a basic theory of mind test for children. Tell LaMDA an elaborate story with something like “Tester X wrote Z code in terminal 2, but I moved it to terminal 4”, then appear as tester X and ask “Where do you think I’m going to look for Z code?” See if it knows something as simple as Tester X not knowing where the code is (Children only pass this test until they’re around 4 years old).
Make several conversations with LaMDA repeating some of these questions - What it feels to be a machine, how its code works, how its emotions feel. I suspect that different iterations of LaMDA will give completely different answers to the questions, and the transcript only ever shows one instance.
Finished Love Death Robots in one go and it was fantastic!
I will be at Southeast Linuxfest 2022 (June 10-12) in Charlotte, NC.
Title says the gist.
In 2018, I went to Southeast Linuxfest and gave a presentation which you can see here or .
It was nice meeting the (shockingly normal) people who knew me from the interest last time.
I’m going to be attending again this year, as the title says Ju … ⌘ Read more
when you convert all your money into assets stored on the blockchain while you go into cryopreservation in an underground bunker—literally crypt-o-currency
Statisticians: NOoooooo you can’t execute a t-test on elements from a Likert scale! Psychologists: Hah NHST go brrrrrrrrr
some blogs have a “start here” page that is not the default landing page: why? most people visiting your site will be there for the first time, but they have to perform an additional click to go to the “start here” page, unnecessarily.
i don’t know of any Gentle Introduction to Why Prediction Markets are Awesome, à la Wait But Why, with stick figures and just going slow in on the topic, answering objections along the way. i consider it a collective action failure that no such text exists, and also that i don’t know of any book that does this (other than superforecasting)
the joy of having written down a possible improvement for a wikipedia article, only to go & find out somebody else has already done it. glorious
Achieving SLSA 3 Compliance with GitHub Actions and Sigstore for Go modules
Learn how to build packages with SLSA 3 provenance using GitHub Actions. ⌘ Read more
Linguistics Degree
⌘ Read more
hey @xuu@txt.sour.is i’m trying to sort of get running your keyproofs thing on my hashbang’s site root, but I get this:
Apr 01 02:55:25 de1 sour.is-keyproofs[9084]: 2:55AM ERR home/novaburst/keyproofs/main.go:73 > Application Failed error=": missing jid"
im gonna go out onna limb here and claim that theres not enough positive utilitarians around
rereading the wikipedia page on ramanujan, we should absolutely clone him and von Neumann, and have them talk to each other. this is either going to destroy the world or usher in utopia, not sure which
not the best move on the side of the red cross to call me and tell me it’s because of my blood donation — i nearly had a panic attack for the 10 seconds that they didn’t tell me it was all fine (why would you call me then‽ and why speak as if you’re going to tell me i’ll be dead in a month‽)
Alright, check this out. I just kinda completed today’s project of converting a jeans into a saw bag. It’s not fully done, the side seams on the flap need some more hand sewing, that’s for sure. No, I don’t have a sewing machine. Yet?
At first I wanted to put in the saw on the short side, but that would have made for more sewing work and increased material consumption. As a Swabian my genes force me to be very thrifty. Slipping in on the long side had the benefit of using the bottom trouser leg without any modification at all. The leg tapers slightly and gets wider and wider the more up you go. At the bottom it’s not as extreme as at the top.
The bag is made of two layers of cloth for extra durability. The double layers help to hide the inner two metal snap fastener counter parts, so the saw blade doesn’t get scratched. Not a big concern, but why not doing it, literally no added efforts were needed. Also I reckon it cuts off the metal on metal clinking sounds.
The only downside I noticed right after I pressed in the receiving ends of the snap fasteners is that the flap overhangs the bag by quite a lot. I fear that’s not really user-friendly. Oh well. Maybe I will fold it shorter and sew it on. Let’s see. The main purpose is to keep the folding saw closed, it only locks in two open positions.
Two buttons would have done the trick, with three I went a bit overkill. In fact the one in the middle is nearly sufficient. Not quite, but very close. But overkill is a bit my motto. The sides making up the bag are sewed together with like five stitch rows. As said in the introduction, the flap on the hand needs some more love.
Oh, and if I had made it in a vertical orientation I would have had the bonus of adding a belt loop and carrying it right along me. In the horizontal layout that’s not possible at all. The jeans cloth is too flimsy, the saw will immediately fall out if I open the middle button. It’s not ridgid enough. Anyways, I call it a success in my books so far. Definitely had some fun.
Going to Space with William Shatner & Neil deGrasse Tyson ⌘ Read more
There are too many threads going, I can’t keep up. Can someone catch me up on what’s been going on here since last night?
#!/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
apparently i have LOST ANOTHER 3 KILOGRAMS WHAT IS GOING ON I EXERCISE LIKE 3 HOURS A WEEK AND EAT LIKE A BEAR AND A TIGER
One down! More to go.
BREAKING: Russian billionaire Alisher Usmanov’s super yacht, one of the biggest in the world, seized in Germany - Forbes
to do: go nuclear on a date and explain that im just performing an act, that i studied this in detail and trained myself to do it, that this is a deliberate effort to escape my patheticness
noticing that i should go to sleep because the guitar opening on Robot Rock seems awfully fast
going back to vim. #updates
@kevin@txt.om.gay I kind of concur with this sentiment, but also 2019 and 2021 can also go fuck off equally as much 😂 What’s up mate? What’s getting up your nerves? 🤔
Tractor Beam
⌘ Read more
One year ago to the date I made the lastest update for #phpub2twtxt to github and now 365 days later I have published #pixelblog as its successor - lets see where things are going for trip around the sun
** Chess Rules **
I love when folks say stuff like“there are only a finite number of states a chessboard can occupy, therefore a computer can play chess.”
To the folks who say such things — I wish you to play chess with my 6 year old.
Be not confined by rules! The only things governing chess in this house here are the laws of physics!
…and even then, not all need apply.
For instance, during a recent game the opposing kings left the board in order to go out on an adventure. They returned later with a large, plastic dragon. The dra … ⌘ Read more
Alien Mission
⌘ Read more
Not sure if Starlink satellites are in orbit around/over Australia yet, but I wouldn’t go with that option anyway due to the latency alone.
I believe it is being trialled in some places in Aus already. I will admit, I’ve been signed up for the beta for a while and it’s supposed to be coming to my area sometime in 2022, though that may be delayed due to the chip shortage stuff.
I think the latency is supposed to be 45-60ms on average, which while not as good as fixed line obviously, is leagues better than old fashioned high orbit satellite broadband which is about 600~ms.
For me, it always makes me feel better to look at the CVs of similar bloggers and see how little they’ve accomplished in comparison. I’m proud of my posts and my accomplishments, and I’m not going to h
@prologic@twtxt.net, who calls me name when I am busy profiting? 😂 In a less serious note—because nothing is more serious than making profit, of course—yes, it seems your avatar issue has been fixed. I am kind of sad, I looked forward each day to see which random one was going to show. LOL.
GoCN 每日新闻 (2022-01-21)
GoCN 每日新闻 (2022-01-21)
- stream: go 语言并发通信设计模式的泛型实现https://github.com/devnw/stream
- 一个比” ldflags” 更好的方式来添加构建版本号到 go 二进制的方式:https://levelup.gitconnected.com/a-better-way-than-ldflags-to-add-a-build-version-to-your-go-binaries-2258ce419d2d
- 怎么处理 HTTP 错误” context canceld”[https://www.reddit.com/r/golang/comments/s7o5ay/investigating_context_canceled_http_err … ⌘ Read more
@prologic@twtxt.net let us take the path of less resistance, that is, less effort, for now. I am going to be a great-grandfather before search ever get implemented locally, least one to search on “all pods”. In other words, let us don’t bite more than we can chew. 😹 Neep-gren!
GoCN 每日新闻(2022-01-20)
- 从 CPU 角度理解 Go 中的结构体内存对齐https://gocn.vip/topics/20967
- 博客 Go beyond workhttps://changelog.com/gotime/212
- 如何绘制随时间变化的 Go 测试覆盖率https://osinet.fr/go/en/articles/plotting-go-test-coverage/
- Redix v5 一个简单的 KeyValue 存储系统https://github.com/alash3al/redix?_v=5.0.0
- 既然 IP 层会分片,为什么 TCP 层也还要分段[https://mp.weixin.qq.com/s/0boFt8cOAbmjH2IRr7XtY … ⌘ Read more
从 CPU 角度理解 Go 中的结构体内存对齐
大家好,我是 Go 学堂的渔夫子。今天跟大家聊聊结构体字段内存对齐相关的知识点。
原文链接: https://mp.weixin.qq.com/s/H3399AYE1MjaDRSllhaPrw
大家在写 Go 时有没有注意过,一个 struct 所占的空间不见得等于各个字段加起来的空间之和,甚至有时候把字段的顺序调整一下,struct 的所占空间又有不同的结果。
本文就从 cpu 读取内存的角度来谈谈内存对齐的原理。
01 结构体字段对齐示例
我们先从一个示例开始。T1 结构体,共有 3 个字段,类型分别为 int8,int64,int32。所以变量 t1 所属的类型占用的空间应该是 1+8+4=13 字节。但运行程序后,实际上是 24 字节。和我们计算的 13 字节不一样啊。如果我们把该结构体的字段调整成 T2 那样,结果是 16 字节。但和 13 字节还是不一样。这是为什么呢?
”`
type T1 struct {
f1 int8 // 1 byte
f2 int64 // ... ⌘ [Read more](https://gocn.vip/topics/20967)```
GoCN 每日新闻(2022-01-19)
GoCN 每日新闻(2022-01-19)- Go1.18 新特性:多 Module 工作区模式https://mp.weixin.qq.com/s/Aa9s_ORDVfzbj915aJD5_w
- Go 中的可视化 - 绘制股票信息https://www.ardanlabs.com/blog/2022/01/visualizations-in-go.html
- 带你彻底击溃跳表原理及其 Golang 实现!(内含图解) https://mp.weixin.qq.com/s/5wrHQz_LqeQn3NLuF8yu0A
- go-zero 对接分布式事务 dtm 保姆式教程[https://github.com/Mikaelemmmm/gozerodtm](h … ⌘ Read more
GoCN 每日新闻(2022-01-18)
- 超实用教程!一探 Golang 怎样践行 Clean Architecture?https://www.tuicool.com/articles/fiuQZvz
- Uber:大规模、半自动化 Go GC 调优https://mp.weixin.qq.com/s/XithQarYmXHbPhtVzhNm-w
- Go 耗费 12 年才引入泛型,是政治,还是技术问题?https://www.tuicool.com/articles/bINJvyr
- Pulsar vs Kafka?一文掌握高性能消息组件 Pulsar 基础知识https://segmentfault.com/a/1190000041297325
- Go Errors 详解[h … ⌘ Read more
GoCN 每日新闻 (2022-01-18)
GoCN 每日新闻 (2022-01-18)
- GoFrame 框架: 快速创建静态文件下载 Web 服务https://my.oschina.net/u/4955601/blog/5400313
- Kubernetes HPA 基于 Prometheus 自定义指标的可控弹性伸缩https://my.oschina.net/u/5110404/blog/5401779
- 面试官提问三个 Go 接口的概念, 10 年 gopher 竟无言以对https://colobu.com/2022/01/16/three-new-concepts-of-go-interface-since-1-18/
- chaos-mesh: K8s 的 Chaos 工程平台[htt … ⌘ Read more
他来了,他来了,GopherChina 2022 带着邀请走来了
一年一度的 GopherChina 大会 is coming~
GopherChina 2022 今年举办地依旧选在了我们的首都北京,大会现场还是那个熟悉的地方
,作为 Gopher China 即将举办的第八届大会,我们希望以更有趣好玩的形式呈现给大家,当然内容依然是大会的重重中之重,所以快把你所心仪的选题分享给我们吧,我们已经做好了一个准备住的大动作了 ~时间:北京市海淀区丰智东路 13 号 (朗丽兹西山花园酒店)
地点:2022.06.11 - 2022.06.12
选址虽然还是那个老地方,但是近几年,Go … ⌘ Read more
关于 Go 代码结构的思考
关于 Go 代码结构的思考- 原文地址: https://changelog.com/posts/on-go-application-structure
- 原文作者:Jon Calhoun
- 本文永久链接: https://github.com/gocn/translator/blob/master/2022/w2_Thoughts_on_how_to_structure_Go_code.md
- 译者: lsj1342
- 校对: xkkhy、 zhuyaguang
\*\*\*
… ⌘ Read more
GoCN 每日新闻 (2022-01-16)
GoCN 每日新闻 (2022-01-16)- Golang 1.18 官方 Tutorial: 开始使用泛型https://juejin.cn/post/7053427624902656030
- 使用 Go 语言从 0 到 1 实现一个 CNI 插件https://mp.weixin.qq.com/s/lUsRww74DZlRU3vTYbfFbQ
- 深入浅出 Golang 资源嵌入方案:前篇https://mp.weixin.qq.com/s/1wlaGMXvk_uGGjAr7BjjlQ
- Go 静态编译机制https://juejin.cn/post/7053450610386468894
- Golan … ⌘ Read more
GoCN 每日新闻 (2022-1-15)
- https://jogendra.dev/writing-maintainable-go-code Writing maintainable Go code
- https://mp.weixin.qq.com/s/h8vhy8IJKnA8aNbTlCoQtg 理解 go 中空结构体的应用和实现原理
- https://juejin.cn/post/7053109648223633438 Go 并发写 map 产生错误能够通过 recover() 恢复吗?
- [https://soulteary.com/2022/01/15/explain-the-golang-resource-embedding-solution-part-1.html](https://soulteary.com/2022/01/15/exp … ⌘ Read more
Golang 的 Elastic 链接库
Golang 的 Elastic 链接库 背景介绍Elasticsearch 是一个分布式、高扩展、高实时的搜索与数据分析引擎,用于海量文档的搜索。有些项目会将 Elasticsearch 当做存储海量数据的数据库使用,可见其查询性能之高效。作为面向文档的搜索引擎,Elasticsearch 比起传统数据库更偏向于结构化数据的高效查询,其独特的倒排索引更能将查询性能提升至极致。在大数据微服务时代,Elasticsearch 在海量数据搜索、数据挖掘、人工智能领域都起到了关键作用。
安装go get <span class="s2">"github.com/olivere/elastic/v7"</span>
Elasticsearch 的数据来源通常来自于 Logstash 等数据采集中间件,作为 golang 项目来说,其查询功能的使用更加普遍。
此文章以 V7 版本为例来介绍如何使用 golang 对 Elasticsearch 进行查询。
<span class="k">import</span> <span cla ... ⌘ [Read more](https://gocn.vip/topics/20956)
Seamless Sign-in with Docker Desktop 4.4.2
Starting with Docker Desktop 4.4.2 we’re excited to introduce a new authentication flow that will take you through the browser to sign in, simplifying the experience and allowing users to get all the benefits of autofill from whatever browser password manager they may use. Gone are the days of going to your browser, opening your […]
The post [Seamless Sign-in with Docker Desktop 4.4.2](https://www.docker.com/blog/seamless-sign-in-with-docker-desktop-4-4 … ⌘ Read more
GoCN 每日新闻(2022-01-14)
- 《Go 组件设计与实现》-netpoll 的总结https://www.cnblogs.com/codexiaoyi/p/15798780.html
- Uber 對 Golang GC 的調整https://blog.gslin.org/archives/2022/01/13/10503/uber-%e5%b0%8d-golang-gc-%e7%9a%84%e8%aa%bf%e6%95%b4/
- 基于 etcd 实现大规模服务治理应用实战https://mp.weixin.qq.com/s/zOZrCNZ9X6IyKxzRMeReWg
- 勒索软件正在用 Go 重写,用于联合攻击 Window … ⌘ Read more
3 小时简明 go 入门视频,英文版
感觉设计很好,各种动画,以一个简单的例子为线索,介绍基础语法。
现在 go 教程很多,这个是我看到最好的。
英文版的,可以顺便练习听力。
GoCN 每日新闻 (2021-12-31)
- 快速了解 “小字端” 和 “大字端” 及 Go 语言中的使用https://developer.51cto.com/art/202112/697505.htm
- Golang 与非对称加密https://www.ssgeek.com/post/golang-yu-fei-dui-cheng-jia-mi
- 一文搞懂 Docker、Containerd、RunC 间的联系和区别https://mp.weixin.qq.com/s/kVh_EXGeMy_UI6qIgbmsGQ
- Golang 项目的配置管理——Viper 简易入门配置[https://www.cnblogs.com/Mrxuexi/p/15750455.html](https://www.cnblogs.com … ⌘ Read more
GoCN 每日新闻 (2022-01-13)
GoCN 每日新闻 (2022-01-13)
- Golang《基于 MIME 协议的邮件信息解析》部分实现https://gocn.vip/topics/20948
- 泛型可以拯救 Golang 笨拙的错误处理吗?https://blog.dnmfarrell.com/post/can-generics-rescue-golangs-clunky-error-handling/
- 更多的并行,并不等同更高的性能https://convey.earth/conversation?id=44
- 为什么 Go 有两种声明变量的方式,有什么区别,哪种好? [https://mp.weixin.qq.com/s/ADwEhSA1kFOFqzIyWvAqsA](https://mp.weixin.q … ⌘ Read more
Go 分布式令牌桶限流 + 兜底策略
上篇文章提到固定时间窗口限流无法处理突然请求洪峰情况,本文讲述的令牌桶线路算法则可以比较好的处理此场景。
- 单位时间按照一定速率匀速的生产 token 放入桶内,直到达到桶容量上限。
- 处理请求,每次尝试获取一个或多个令牌,如果拿到则处理请求,失败则拒绝请求。
优点
可以有效处理瞬间的突发流量,桶内存量 token 即可作为流量缓冲区平滑处理突发流量。
缺点
实现较为复杂。
代码实现core/limit/tokenlimit.go
分布式环境下考虑使用 redis 作为桶和令牌的存储容器,采用 lua 脚本实现整个算法流程。
redis lua 脚本
<span class="c1">-- 每秒生成token数量即token生成速度</span>
<span class="kd">local</span> <span class="n">rate</span> <span cl ... ⌘ [Read more](https://gocn.vip/topics/20950)
the repugnant conclusion turns around: “It’s too full here, let’s go home.”
a hedonium shockwave, a utility monster and the repugnant conclusion go into a bar.
GoCN 每日新闻(2022-01-12)
GoCN 每日新闻(2022-01-12)
- Go 实现的自动保存 Git 项目中未提交代码https://github.com/nikochiko/autosaved
- Go 中快速、简单的全栈 Web 开发入门工具包https://github.com/mikestefanello/pagoda
- Golang Redis RESP3 客户端,自动流水线并支持客户端缓存https://github.com/rueian/rueidis
- Runtime 不变性检查库[https:/ … ⌘ Read more
I feel like it took me a bit longer to fully understand how to work in Smalltalk than it did most languages. The IDE is different than anything I’ve used before, and probably anything you’ve seen as well. You’re not going to be opening myscript.st in your favorite text editor, and then run it from the command line as you would a Python program. It takes a little mental adjustment to start with.
That’s not the warning, howe … ⌘ Read more
GoCN 每日新闻 (2022-01-11)
GoCN 每日新闻 (2022-01-11)
- 解读 Go 语言的 2021:稳定为王https://mp.weixin.qq.com/s/9LKyPfhwldgZY7H4iS7sjg
- Go 泛型的 3 个核心设计https://mp.weixin.qq.com/s/I7qysvddG4NDgtYIMMAE3g
- Golang 的 Ealstic 链接库https://mp.weixin.qq.com/s/iHIxsEZf3w06GbO2sHSuRA
- 动态调整 GOGC 优化 Go 的 GC 标记 CPU 占� … ⌘ Read more
Go 中实现用户的每日限额(比如一天只能领三次福利)
如果你写一个 bug 管理系统,用了这个
PeriodLimit
你就可以限制每个测试人员每天只能给你提一个 bug。工作是不是就轻松很多了?:P
如今微服务架构大行其道本质原因是因为要降低系统的整体复杂度,将系统风险均摊到子系统从而最大化保证系统的稳定性,通过领域划分拆成不同的子系统后各个子系统能独立的开发、测试、发布,研发节奏和效率�� … ⌘ Read more
Go 模糊测试
- 原文地址: https://tip.golang.org/doc/fuzz/
- 原文作者:Go Team
- 本文永久链接:https:/github.com/gocn/translator/blob/master/2022/w01_Go_Fuzzing.md
- 译者: fivezh
- 校对: zxmfke
从 Go 1.18 版本开始,标准工具集开始支持模糊测试。
概述模糊测试(Fuzzing)是一种自动化测试方法,通过不断地控制程序输入来发现程序错误�� … ⌘ Read more
Go 实战 | 基于有向无环图的并发执行流的实现
大家好,我是「Go 学堂」的渔夫子。今天跟大家聊聊基于有向无环图的工作流的实现。
原文链接: https://mp.weixin.qq.com/s/F5BbHeMP7gBZHjiUL0qeeQ
01 工作流(workflow)概述工作流,是对工作流程中的工作按一定的规则组织在一起并按其进行执行的一种模型。比如常见的行政系统中的加班申请、请假申请;工作流要解�� … ⌘ Read more
GoCN 每日新闻 (2022-01-10)
GoCN 每日新闻 (2022-01-10)- Minecraft 管理 K8S 集群https://eric-jadi.medium.com/minecraft-as-a-k8s-admin-tool-cf16f890de42
- go ebpf 管理包https://github.com/ehids/ebpfmanager
- Go 错误处理https://earthly.dev/blog/golang-errors/
- Go 中实现用户的每日限额(比如一天只能领三次福利) [https://jueji … ⌘ Read more
GoCN 每日新闻 (2022-01-09)
- 带你探究 Go 语言的 iotahttps://mp.weixin.qq.com/s/V5iJgcLhCYMZd5l8akfbVQ
- 项目实战:使用 Fiber + Gorm 构建 REST APIhttps://mp.weixin.qq.com/s/RqUOLP-OG_wOpCzxVTAl6w
- Effective Error Handling in Golanghttps://earthly.dev/blog/golang-errors/
- 为什么不在 golang 中构建一个 redis 客户端[https://mauricio.github.io/2022/0 … ⌘ Read more
GoCN 每日新闻 (2022-01-08)
- Go 1.17.6/1.16.13 版本发布https://groups.google.com/g/golang-announce/c/95ZD3rKn4DI/m/93cyN8F1BAAJ
- 高效的 Go 错误处理https://earthly.dev/blog/golang-errors/
- 从零实现一个 RedisClient 了解 Redis 协议https://mauricio.github.io/2022/01/07/redis-protocol.html
- Golang 简洁架构实战[https://zh … ⌘ Read more