Telegram Web Link
Wow, after almost a year of silence a new info about generics in Go comes up officially 👏 the update brings to us:
- a new, updated design draft;
- an experimental tool to try generics from the draft by yourself;
- and a few lines about what’s going to happen next.

Here I’d like to post a quote from the post and then allow you to read the rest by the link below.

>>>
Introduction
It’s been almost a year since we last wrote about the possibility of adding generics to Go. It’s time for an update.

Updated design
We’ve been continuing to refine the generics design draft. We’ve written a type checker for it: a program that can parse Go code that uses generics as described in the design draft and report any type errors. We’ve written example code. And we’ve collected feedback from many, many people—thanks for providing it!

Based on what we’ve learned, we’re releasing an updated design draft. The biggest change is that we are dropping the idea of contracts. The difference between contracts and interface types was confusing, so we’re eliminating that difference. Type parameters are now constrained by interface types. Interface types are now permitted to include type lists, though only when used as constraints; in the previous design draft type lists were a feature of contracts. More complex cases will use a parameterized interface type.

We hope that people will find this design draft simpler and easier to understand.

https://blog.golang.org/generics-next-step
Let's build a Full-Text Search engine in Go

Full-Text Search (FTS) is a technique for searching text in a collection of documents. A document can refer to a web page, a newspaper article, an email message, or any structured text.

Today we are going to build our own FTS engine. By the end of this post, we'll be able to search across millions of documents in less than a millisecond. We'll start with simple search queries like "give me all documents that contain the word cat" and we'll extend the engine to support more sophisticated boolean queries.

https://artem.krylysov.com/blog/2020/07/28/lets-build-a-full-text-search-engine/
About the main function

I love how simple Go’s entry point main function is. It is where your code will start when someone runs your program.

package main

func main() {
// stuff
}


However, main is difficult to test, and it’s not clear how we access the environmental dependencies our program has, such as stdin, stdout, the command line args, the environment variables themselves, etc.

https://pace.dev/blog/2020/02/12/why-you-shouldnt-use-func-main-in-golang-by-mat-ryer.html
How to build a terminal dashboard in Golang in 300 lines of code using termui.

https://levelup.gitconnected.com/building-a-terminal-dashboard-in-golang-in-300-lines-of-code-3b9f83f363a8
Microservices

Hello, world!\n 😄
This week I came across my notes and bookmarks and made a list of resources where to start learning about microservices, and I’d like to share it here. Hope it’s gonna be useful.

📒Posts & Articles:
- 35 Microservices Interview Questions You Most Likely Can't Answer: https://dev.to/aershov24/35-microservices-interview-questions-you-most-likely-can-t-answer-2eoc
- Martin Fowler’s microservices, classic: https://martinfowler.com/articles/microservices.html
- Nice intro into Microservices topic from NGINX team: https://www.nginx.com/blog/introduction-to-microservices/

📚A book to read: “Building Microservices: Designing Fine-Grained Systems” - https://www.amazon.com/Building-Microservices-Designing-Fine-Grained-Systems-ebook/dp/B00T3N7XB4

🧑‍🏫Tutorials
🔴If you’d like to start from practice in a hard mode, feel free to go here:
- “Introduction to Microservices in Gohttps://ewanvalentine.io/microservices-in-golang-part-0/ This is a big and somewhat complete series/tutorial of building a service from scratch in Go, including docker, CI configuration, deployment, Kubernetes and much more things.

🟢Easy-going practices are:
- An option with MySQL: “Build a REST API as a Go microservice together with MySQL” -https://dev.to/johanlejdung/a-mini-guide-build-a-rest-api-as-a-go-microservice-together-with-mysql-27m2
- MongoDB-based example: “Microservices: An Example With Docker, Go, and MongoDB” - https://dzone.com/articles/microservices-an-example-with-docker-go-and-mongod
Go pinned «Microservices Hello, world!\n 😄 This week I came across my notes and bookmarks and made a list of resources where to start learning about microservices, and I’d like to share it here. Hope it’s gonna be useful. 📒Posts & Articles: - 35 Microservices Interview…»
Making SQLite faster in Go 🚀

The most popular way of using sqlite in Go happens to also be the slowest when using it in a concurrent application like a web app. Roll your own connection pool to speed things up.

https://turriate.com/articles/making-sqlite-faster-in-go
Go 1.16 Release Candidate 1 is released!

Go 1.16, due to have its final release in February, is now taking its final form and is ready for your production testing, say the Go team.

>>>
It is cut from release-branch.go1.16 at the revision tagged go1.16rc1. Please try your production load tests and unit tests with the new version, your help testing these pre-release versions is invaluable.

Report any problems using the issue tracker: https://golang.org/issue/new

If you have Go installed already, the easiest way to try go1.16rc1 is by using the go command:
$ go get golang.org/dl/go1.16rc1
$ go1.16rc1 download


You can download binary and source distributions from the usual place: https://golang.org/dl/#go1.16rc1

To find out what has changed in Go 1.16, read the draft release notes: https://tip.golang.org/doc/go1.16

Source: https://groups.google.com/g/golang-announce/c/U_FUHY4wuSc/m/3_Vw3oqpAgAJ
Hello 👋 Recently I've stumbled upon the blog post about //go:embed directive usage: a new feature introduced in Go 1.16,

>> that allows you to include the contents of arbitrary files and directories in your Go application.

Looks quite interesting, have a look:
https://blog.carlmjohnson.net/post/2021/how-to-use-go-embed/
Generic programming proposal has got accepted

https://github.com/golang/go/issues/43651
The Go Wiki includes a slice trick on filtering slices without allocating.

filtered := items[:0]
for _, x := range items {
if condition(x) {
filtered = append(filtered, x)
}
}

This post will attempt to explain how that works: https://abhinavg.net/posts/zero-alloc-slice-filter/
How to work with context.Context: an official blog post.

The documentation for context states:

“Contexts should not be stored inside a struct type, but instead passed to each function that needs it.”

This article expands on that advice with reasons and examples describing why it's important to pass Context rather than store it in another type.

https://blog.golang.org/context-and-structs
Introduction to generics from “Learn Go with tests”: A nice tutorial that takes a step approach to teach generics starting from duplicating code for types, then to interface{}, and finally to generics. And you can run it all in the go2go playground.

https://quii.gitbook.io/learn-go-with-tests/meta/intro-to-generics
A lot of projects use gRPC framework nowadays to build an efficient cross-service communication layer., and usually the calls between services are fast, frequent, and expected to have low latencies.

But what if we have a bit different problem to solve, e.g. handling long-lived streams?

In this article Omri Cohen walk us through an excellent tutorial about how to design gRPC long-lived streaming. Take a look: https://dev.bitolog.com/grpc-long-lived-streaming/
You may be wondering how to...
https://pmihaylov.com/vim-for-go-development/ 🙂
Between Go and Elixir

"Reason wanted me to make a choice, and I am so glad I didn’t. Because the more I kept delving into both Elixir and Go, the more I found out how complementary the two can be to one another."
https://preslav.me/2021/04/23/between-golang-and-elixir/
Top 5 Lessons I learned while working with Go for two years.

In the article, Sayed Alesawy is sharing some of the mistakes and the lessons they faced by doing GoLang development for 2 years:

“ I have been writing Go services for like two years now, both professionally and as personal projects. Using a certain language in numerous projects over an extended period of time allows you to make mistakes, fix them, realize it's still not the best way to do it, fix them again and generally get better the more you get to re-do stuff because each time you try to avoid a mistake you made the last time that caused you a headache throughout that project.”

TLDR;

1. Take the Go highway to Concurrency
2. If it can be singleton, then make it singleton, but do it right!
3. Beware of Blocking Code
4. Graceful Termination and Clean Up
5. Go Modules FTW.

Read more at:
https://sayedalesawy.hashnode.dev/top-5-lessons-i-learned-while-working-with-go-for-two-years
2024/05/20 21:30:42
Back to Top
HTML Embed Code: