Searching txt.sour.is

Twts matching #go
Sort by: Newest, Oldest, Most Relevant

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 👌

⤋ Read More
In-reply-to » Tried to pull down the latest yarn, but I get this: unable to access 'https://git.mills.io/yarnsocial/yarn/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

@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.

⤋ Read More
In-reply-to » Great, last system update broke something, building from current master I get:

@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):

Image

⤋ Read More
In-reply-to » Trying to figure out what sql query maddy does to change user passwords, but first, i'm looking for the subcommand that actually does that... on the source code

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

⤋ Read More

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:

Image

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.

⤋ Read More

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

⤋ Read More

📣 NEW: Announcing the new and improved Yarns search engine and crawler! search.twtxt.netExample 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.

⤋ Read More
In-reply-to » It should be illegal for firealarms to sound a low battery after 10pm and before 8 am.

And that I can silence it without having or go through the full test announcing fire and carbon monox throughout the house.

⤋ Read More
In-reply-to » Today I found that Solarpunk is a thing: https://www.wikiwand.com/en/Solarpunk

@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.

⤋ Read More

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.

⤋ Read More
In-reply-to » Hi, I am playing with making an event sourcing database. Its super alpha but I thought I would share since others are talking about databases and such.

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
}

fig. 1

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)
})

fig. 2

I can tell the function the type being modified and returned using the function argument that is passed in. pretty cray cray.

⤋ Read More
In-reply-to » I did a take home software engineering test for a company recently, unfortunately I was really sick (have finally recovered) at the time 😢 I was also at the same time interviewing for an SRE position (as well as Software Engineering).

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.

⤋ Read More
In-reply-to » I did a take home software engineering test for a company recently, unfortunately I was really sick (have finally recovered) at the time 😢 I was also at the same time interviewing for an SRE position (as well as Software Engineering).

@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.

⤋ 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.

⤋ Read More
In-reply-to » Have you heard about the guy who worked on the Google AI chat bot? It is more than a chat bot and the conversation he published (got put on paid leave for doing that) is pretty scary : https://cajundiscordian.medium.com/is-lamda-sentient-an-interview-ea64d916d917

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.

⤋ Read More

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.

⤋ Read More

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)

⤋ Read More

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

⤋ Read More

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‽)

⤋ Read More

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?

Image

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.

⤋ Read More

@prologic@twtxt.net

#!/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

⤋ Read More

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

⤋ Read More

** 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

⤋ Read More
In-reply-to » Another day, another 5m outage 🤬

@prologic@twtxt.net

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.

⤋ Read More

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

⤋ Read More
In-reply-to » I'm not 100% certain @quark but 🤞 that revert works...

@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.

⤋ Read More

GoCN 每日新闻 (2022-01-21)
GoCN 每日新闻 (2022-01-21)

  1. stream: go 语言并发通信设计模式的泛型实现https://github.com/devnw/stream
  2. 一个比” ldflags” 更好的方式来添加构建版本号到 go 二进制的方式:https://levelup.gitconnected.com/a-better-way-than-ldflags-to-add-a-build-version-to-your-go-binaries-2258ce419d2d
  3. 怎么处理 HTTP 错误” context canceld”[https://www.reddit.com/r/golang/comments/s7o5ay/investigating_context_canceled_http_err … ⌘ Read more

⤋ Read More
In-reply-to » @prologic I am seeing a problem in which not-so-active users, such as myself, are ending up having a blank "Recent twts from..." under their profiles because, I assume, the cache long expired. What can be done about it? Business personalities such as myself can't be around here that often! Could something be implemented so that, say, the last 10 or 20 twts are always visible under one's profile? Neep-gren!

@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!

⤋ Read More

GoCN 每日新闻(2022-01-20)

  1. 从 CPU 角度理解 Go 中的结构体内存对齐https://gocn.vip/topics/20967
  2. 博客 Go beyond workhttps://changelog.com/gotime/212
  3. 如何绘制随时间变化的 Go 测试覆盖率https://osinet.fr/go/en/articles/plotting-go-test-coverage/
  4. Redix v5 一个简单的 KeyValue 存储系统https://github.com/alash3al/redix?_v=5.0.0
  5. 既然 IP 层会分片,为什么 TCP 层也还要分段[https://mp.weixin.qq.com/s/0boFt8cOAbmjH2IRr7XtY … ⌘ Read more

⤋ 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)```

⤋ Read More

GoCN 每日新闻(2022-01-19)

GoCN 每日新闻(2022-01-19)
  1. Go1.18 新特性:多 Module 工作区模式https://mp.weixin.qq.com/s/Aa9s_ORDVfzbj915aJD5_w
  2. Go 中的可视化 - 绘制股票信息https://www.ardanlabs.com/blog/2022/01/visualizations-in-go.html
  3. 带你彻底击溃跳表原理及其 Golang 实现!(内含图解) https://mp.weixin.qq.com/s/5wrHQz_LqeQn3NLuF8yu0A
  4. go-zero 对接分布式事务 dtm 保姆式教程[https://github.com/Mikaelemmmm/gozerodtm](h … ⌘ Read more

⤋ Read More

GoCN 每日新闻(2022-01-18)

  1. 超实用教程!一探 Golang 怎样践行 Clean Architecture?https://www.tuicool.com/articles/fiuQZvz
  2. Uber:大规模、半自动化 Go GC 调优https://mp.weixin.qq.com/s/XithQarYmXHbPhtVzhNm-w
  3. Go 耗费 12 年才引入泛型,是政治,还是技术问题?https://www.tuicool.com/articles/bINJvyr
  4. Pulsar vs Kafka?一文掌握高性能消息组件 Pulsar 基础知识https://segmentfault.com/a/1190000041297325
  5. Go Errors 详解[h … ⌘ Read more

⤋ Read More

GoCN 每日新闻 (2022-01-18)
GoCN 每日新闻 (2022-01-18)

  1. GoFrame 框架: 快速创建静态文件下载 Web 服务https://my.oschina.net/u/4955601/blog/5400313
  2. Kubernetes HPA 基于 Prometheus 自定义指标的可控弹性伸缩https://my.oschina.net/u/5110404/blog/5401779
  3. 面试官提问三个 Go 接口的概念, 10 年 gopher 竟无言以对https://colobu.com/2022/01/16/three-new-concepts-of-go-interface-since-1-18/
  4. chaos-mesh: K8s 的 Chaos 工程平台[htt … ⌘ Read more

⤋ Read More

他来了,他来了,GopherChina 2022 带着邀请走来了

Image

一年一度的 GopherChina 大会 is coming~

GopherChina 2022 今年举办地依旧选在了我们的首都北京,大会现场还是那个熟悉的地方

Image

,作为 Gopher China 即将举办的第八届大会,我们希望以更有趣好玩的形式呈现给大家,当然内容依然是大会的重重中之重,所以快把你所心仪的选题分享给我们吧,我们已经做好了一个准备住的大动作了

Image

时间:北京市海淀区丰智东路 13 号 (朗丽兹西山花园酒店)
地点:2022.06.11 - 2022.06.12

选址虽然还是那个老地方,但是近几年,Go … ⌘ Read more

⤋ Read More

GoCN 每日新闻 (2022-01-16)

GoCN 每日新闻 (2022-01-16)
  1. Golang 1.18 官方 Tutorial: 开始使用泛型https://juejin.cn/post/7053427624902656030
  2. 使用 Go 语言从 0 到 1 实现一个 CNI 插件https://mp.weixin.qq.com/s/lUsRww74DZlRU3vTYbfFbQ
  3. 深入浅出 Golang 资源嵌入方案:前篇https://mp.weixin.qq.com/s/1wlaGMXvk_uGGjAr7BjjlQ
  4. Go 静态编译机制https://juejin.cn/post/7053450610386468894
  5. Golan … ⌘ Read more

⤋ Read More

GoCN 每日新闻 (2022-1-15)

  1. https://jogendra.dev/writing-maintainable-go-code Writing maintainable Go code
  2. https://mp.weixin.qq.com/s/h8vhy8IJKnA8aNbTlCoQtg 理解 go 中空结构体的应用和实现原理
  3. https://juejin.cn/post/7053109648223633438 Go 并发写 map 产生错误能够通过 recover() 恢复吗?
  4. [https://soulteary.com/2022/01/15/explain-the-golang-resource-embedding-solution-part-1.html](https://soulteary.com/2022/01/15/exp … ⌘ Read more

⤋ 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)

⤋ Read More

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

⤋ Read More

GoCN 每日新闻(2022-01-14)

  1. 《Go 组件设计与实现》-netpoll 的总结https://www.cnblogs.com/codexiaoyi/p/15798780.html
  2. 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/
  3. 基于 etcd 实现大规模服务治理应用实战https://mp.weixin.qq.com/s/zOZrCNZ9X6IyKxzRMeReWg
  4. 勒索软件正在用 Go 重写,用于联合攻击 Window … ⌘ Read more

⤋ Read More

GoCN 每日新闻 (2021-12-31)

  1. 快速了解 “小字端” 和 “大字端” 及 Go 语言中的使用https://developer.51cto.com/art/202112/697505.htm
  2. Golang 与非对称加密https://www.ssgeek.com/post/golang-yu-fei-dui-cheng-jia-mi
  3. 一文搞懂 Docker、Containerd、RunC 间的联系和区别https://mp.weixin.qq.com/s/kVh_EXGeMy_UI6qIgbmsGQ
  4. Golang 项目的配置管理——Viper 简易入门配置[https://www.cnblogs.com/Mrxuexi/p/15750455.html](https://www.cnblogs.com … ⌘ Read more

⤋ Read More

GoCN 每日新闻 (2022-01-13)
GoCN 每日新闻 (2022-01-13)

  1. Golang《基于 MIME 协议的邮件信息解析》部分实现https://gocn.vip/topics/20948
  2. 泛型可以拯救 Golang 笨拙的错误处理吗?https://blog.dnmfarrell.com/post/can-generics-rescue-golangs-clunky-error-handling/
  3. 更多的并行,并不等同更高的性能https://convey.earth/conversation?id=44
  4. 为什么 Go 有两种声明变量的方式,有什么区别,哪种好? [https://mp.weixin.qq.com/s/ADwEhSA1kFOFqzIyWvAqsA](https://mp.weixin.q … ⌘ Read more

⤋ Read More

Go 分布式令牌桶限流 + 兜底策略
上篇文章提到固定时间窗口限流无法处理突然请求洪峰情况,本文讲述的令牌桶线路算法则可以比较好的处理此场景。

工作原理
  1. 单位时间按照一定速率匀速的生产 token 放入桶内,直到达到桶容量上限。
  2. 处理请求,每次尝试获取一个或多个令牌,如果拿到则处理请求,失败则拒绝请求。

Image

优缺点

优点

可以有效处理瞬间的突发流量,桶内存量 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)

⤋ 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

⤋ Read More

Go 中实现用户的每日限额(比如一天只能领三次福利)

如果你写一个 bug 管理系统,用了这个 PeriodLimit 你就可以限制每个测试人员每天只能给你提一个 bug。工作是不是就轻松很多了?:P

如今微服务架构大行其道本质原因是因为要降低系统的整体复杂度,将系统风险均摊到子系统从而最大化保证系统的稳定性,通过领域划分拆成不同的子系统后各个子系统能独立的开发、测试、发布,研发节奏和效率�� … ⌘ Read more

⤋ Read More

Go 模糊测试

从 Go 1.18 版本开始,标准工具集开始支持模糊测试。

概述

模糊测试(Fuzzing)是一种自动化测试方法,通过不断地控制程序输入来发现程序错误�� … ⌘ Read more

⤋ Read More

Go 实战 | 基于有向无环图的并发执行流的实现
大家好,我是「Go 学堂」的渔夫子。今天跟大家聊聊基于有向无环图的工作流的实现。

原文链接: https://mp.weixin.qq.com/s/F5BbHeMP7gBZHjiUL0qeeQ

01 工作流(workflow)概述

工作流,是对工作流程中的工作按一定的规则组织在一起并按其进行执行的一种模型。比如常见的行政系统中的加班申请、请假申请;工作流要解�� … ⌘ Read more

⤋ Read More