🇺🇦 Go for two :)
1.18K subscribers
22 photos
3 files
184 links
Telegram channel about tricks and engineering practices in the Go programming language over a cup of coffee ☕️.

author: @a_soldatenko
personal blog: https://asoldatenko.org

#golang #go #kubernetes #debugging
加入频道
Happy New Year’; DROP TABLE 2020;--
Note about cuelang

Недавно нашел интересный проект CUElang [1] (естественно написанный на Go).
Расшифровывается как Configure, Unify, Execute. Cue - это язык для конфигураций со встроенной проверкой типов. Вообщем, выглядит как попытка улучшить ситуацию с тем адом из yaml файлов, который сейчас есть.

Tl;dr чтобы быстро понять что к чему, можно пройти туториал [2], в котором предлагается перевести k8s *yaml файлы на *cue с валидацией и блэкджеком.

Так же есть смысл познакомиться с концепциями [3]. Из приятного, то что сразу есть консольная утилита cue, которая умеет например форматировать cue файлы =), больше инфы тут [4].
P.S. выглядит примерно так:
  $ cat <<EOF > foo.yaml
kind: Service
name: booster
EOF

# include the parsed file as an emit value:
$ cue import foo.yaml
$ cat foo.cue
{
kind: Service
name: booster
}


[1] https://github.com/cuelang/cue
[2] https://github.com/cuelang/cue/blob/v0.2.2/doc/tutorial/kubernetes/README.md
[3] https://cuelang.org/docs/concepts/logic/
[4] https://github.com/cuelang/cue/blob/master/doc/cmd/cue.md
Go blogs

1 A Journey With Go https://medium.com/a-journey-with-go
2 Applied Go https://appliedgo.net
3 Ardan Labs’ Blog https://ardanlabs.com/blog
4 Dave Cheney’s Blog https://dave.cheney.net
5 DEV’s Go Tag https://dev.to/t/go
6 Digital Ocean’s Go Series https://digitalocean.com/community/tutorial_series/how-to-code-in-go
7 Eli Bendersky’s Blog https://eli.thegreenplace.net/tag/go
8 Go By Example https://gobyexample.com
9 Go Web Examples https://gowebexamples.com
10 Go’s Articles Wiki https://github.com/golang/go/wiki/Articles
11 Golang Bot https://golangbot.com
12 Golang Programs https://golangprograms.com
13 GolangCode https://golangcode.com
14 Gopher Academy Blog https://blog.gopheracademy.com
15 Gopher Guides https://gopherguides.com/articles
16 Hashnode’s Go Tag https://hashnode.com/n/go
17 Ilija Eftimov’s Blog https://ieftimov.com
18 ITNEXT’s Blog https://itnext.io/tagged/golang
19 Just For Func https://medium.com/justforfunc
20 Learn The Go Programming Language https://medium.com/learning-the-go-programming-language
21 Official Go Blog https://blog.golang.org
22 Russ Cox’s Blog https://research.swtch.com
23 Tit Petric’s Blog https://scene-si.org
24 Tutorial Edge https://tutorialedge.net/course/golang
25 Thoughts’ Go Topic https://utcc.utoronto.ca/~cks/space/blog/__TopicGoWandering

from reddit comments (https://www.reddit.com/r/golang/comments/kul1hd/go_blogs_rated_by_consistency_writing_quality_and/):
Jon Calhoun's Blog https://www.calhoun.io/
Bojan Živanović's Blog https://bojanz.github.io/
Jack Christensen's Blog https://www.jackchristensen.com/
Matt Layher's https://mdlayher.com/blog/
Johan Brandhorst-Satzkorn's Blog https://jbrandhorst.com/
Filippo Valsorda's Blog https://blog.filippo.io/
Peter Bourgon's Blog https://peter.bourgon.org/blog/

Other:
https://github.com/sanmak/awesome-blogs
https://www.mohitkhare.com/categories/golang

Если читаете что-то еще пишите в комменты :)

happy Monday!
Нашел интересный проект Fortio, начиналась как инструмент нагрузочного тестирования для service mesh Istio, а теперь превратилась в собственный проект.

Написан естественно на Go и поставляется также в докере размером 3Mb, умеет считать сразу персентили и показывать результаты в небольшой веб страничке.

Больше деталей в README.md https://github.com/fortio/fortio

P.S.
Добавил по традиции в https://github.com/andriisoldatenko/awesome-performance-testing.
Если вы знаете еще какие-то performance тулы дайте знать в комментах либо можно сразу PR.
go-internals is a work-in-progress book about the internals of the Go (1.10+) programming language.

Автор правда забил 3 года назад, но то что есть очень интересное чтиво.

https://github.com/teh-cmc/go-internals
gitbatch утилита для управления сразу несколькими git репозиториями)

tl;dr https://asciinema.org/a/lxoZT6Z8fSliIEebWSPVIY8ct

https://github.com/isacikgoz/gitbatch
Если вы интересуетесь eBPF, то вот вам примеры от Leo создателя Falco.

https://github.com/leodido/go-ebpf-examples

P.S. под капотом тот самый https://github.com/iovisor/gobpf о котором я писал уже ранее -> https://yangx.top/golang_for_two/96
FOSDEM 2021 Go dev room

В этом году FOSDEM пройдет online, в субботу 6 февраля!

И уже есть расписание https://fosdem.org/2021/schedule/track/go/
Всем известный Ben Johnson, он же автор BoltDB сегодня зарелизил новый проект Litestream.

Litestream - инструмент потоковой (stream) репликации для SQLite. Он работает как фоновый процесс и безопасно реплицирует частичные изменения в другой файл или AWS S3. Litestream взаимодействует с SQLite только через API SQLite, поэтому он безопасен для ваших данных.

Как обычно фидбэк в твиттер автору: https://twitter.com/benbjohnson/status/1354468790558281731

Ссылка на код: https://github.com/benbjohnson/litestream
Сегодня зарелизился Delve v1.6.0

Из важных изменений:
- Go 1.16 support, Apple M1 support, syntax highlighting for code blocks, and more!


dlv version
Delve Debugger
Version: 1.6.0
Build: 75485427957fba167a6eaca76b1ee9549d62916f

Полный CHANGELOG -> https://github.com/go-delve/delve/blob/master/CHANGELOG.md#160-2021-01-28
Automatically Detecting and Fixing Concurrency Bugs in Go
Software Systems

https://songlh.github.io/paper/gcatch.pdf

Также у автора есть интересный репозиторий https://github.com/system-pclub/go-concurrency-bugs

Ну и список багов

https://docs.google.com/spreadsheets/d/1mDxB6IRxrTodF9CrmpUu72E6673y5s9BkjKuTjtx1qc/edit#gid=0

подсмотрел у https://twitter.com/dgryski
golang deep comparison for testing:

https://github.com/maxatome/go-testdeep

import (
"testing"
"time"
)

func TestCreateRecord(t *testing.T) {
before := time.Now().Truncate(time.Second)
record, err := CreateRecord()

if err != nil {
t.Errorf("An error occurred: %s", err)
} else {
expected := Record{Name: "Bob", Age: 23}

if record.Id == 0 {
t.Error("Id probably not initialized")
}
if before.After(record.CreatedAt) ||
time.Now().Before(record.CreatedAt) {
t.Errorf("CreatedAt field not expected: %s", record.CreatedAt)
}
if record.Name != expected.Name {
t.Errorf("Name field differs, got=%s, expected=%s",
record.Name, expected.Name)
}
if record.Age != expected.Age {
t.Errorf("Age field differs, got=%s, expected=%s",
record.Age, expected.Age)
}
}
}

можно переписать в:
import (
"testing"
"time"

"github.com/maxatome/go-testdeep/td"
)

func TestCreateRecord(t *testing.T) {
before := time.Now().Truncate(time.Second)
record, err := CreateRecord()

if td.CmpNoError(t, err) {
td.Cmp(t, record.Id, td.NotZero(), "Id initialized")
td.Cmp(t, record.Name, "Bob")
td.Cmp(t, record.Age, 23)
td.Cmp(t, record.CreatedAt, td.Between(before, time.Now()))
}
}


P.S. в проде не юзал но выглядит аккуратно, особенно когда происходит расхождение с ожидаемым результатом.
A Golang library for generating high-entropy random passwords similar to 1Password or LastPass.

Example passwords this library may generate:
0N[k9PhDqmmfaO`p_XHjVv`HTq|zsH4XiH8umjg9JAGJ#\Qm6lZ,28XF4{X?3sHj
7@90|0H7!4p\,c<!32:)0.9N
UlYuRtgqyWEivlXnLeBpZvIQ
Q795Im1VR5h363s48oZGaLDa
wpvbxlsc


https://github.com/sethvargo/go-password

Из интересного сразу идет моком для тестов:
// func MyFunc(p *password.Generator)
func MyFunc(p password.PasswordGenerator) {
// ...
}

func TestMyFunc(t *testing.T) {
gen := password.NewMockGenerator("canned-response", false)
MyFunc(gen)
}