Made a library? Written a blog post? Found a useful tutorial? Share it with the Go community here or just enjoy what everyone else has found!
github.com/pioz/god
config is an easy-to-use package that supports reading configuration into a struct from files, environment variables and command-line arguments. All you need is to declare a structure that will hold your configuration and call Read
method. The library will pool the values from a config file in any well-known format, from env vars that follows simple naming convention, or from command-line arguments
go get github.com/num30/config
Hello
I built a URL shortener for this site using Encore.dev for all the backend including hosting the service in Encore Cloud.
Code: Golangflow Urler Hosted in Encore Cloud - Developed using Encore.dev
My Golang Job Board with Jobs for Golang Developers is up since 2019, with its own section for Remote Golang Jobs
Configurable Golang email validator. Verify email via Regex, DNS, SMTP and even more! Be sure that email address valid and exists: https://github.com/truemail-rb/truemail-go
Writing maintainable code is essential. Clarity, readability, and simplicity are all aspects of maintainability. It should make the process easy for someone to join your project or maintain it after someone leaves. Maintainability is measured by how effortless it is to introduce changes and the amount of risk associated with those changes. To write Go effectively, it is crucial to understand its properties and idioms and apply the established conventions related to naming, program construction, formatting, etc.
Find the full blog here: https://jogendra.dev/writing-maintainable-go-code
smtpmock
will help you to mimic any SMTP server behaviour for your test environment. It's lightweight configurable multithreaded SMTP fake server. It meets the minimum requirements specified by RFC 2821 & RFC 5321: https://github.com/mocktools/go-smtp-mock
On the Martian blog, Svyatoslav Kryukov enters into a fantasy realm, and is forced to imagine that ✨everything must be written in Go!✨
Read and learn to write Go in Ruby, gaining the ability to modify Ruby exactly as you desire.
In this article, he covers:
👉 Read the tale: https://evilmartians.com/chronicles/a-no-go-fantasy-writing-go-in-ruby-with-ruby-next
Goapp is an opinionated guideline to structure a Go web application/service (or could be extended for any application). These opinions were formed over a span of 5+ years building web applications/services with Go, trying to implement DDD (Domain Driven Development) & Clean Architecture. Even though I've mentioned go.mod and go.sum, this guideline works for 1.4+ (i.e. since introduction of the special 'internal' directory).
Tant que Go est encore en version 1.15.x et n'a pas encore les embeds de fichier en standard, voici comment utiliser pkger
pour embarquer vos templates ou tout autre asset:
https://osinet.fr/go/articles/inclusion-de-templates-avec-pkger/
While Go is still 1.15.x and doesn't yet have standard embeds, here is how to embed templates (or whatever assets you need) in your code with pkger
.
https://osinet.fr/go/en/articles/bundling-templates-with-pkger/
Parte 2 de 3 onde esclareço o funcionamento dos comandos presentes na ferramenta CLI go.
Parte 1 de 3 onde esclareço o funcionamento dos comandos presentes na ferramenta CLI go.
As a Golang developer, you probably have encountered import cycles. Golang do not allow import cycles. Go throws a compile-time error if it detects the import cycle in code. In this post, let’s understand how the import cycle occurs and how you can deal with them.
Find full blog here:
https://jogendra.dev/import-cycles-in-golang-and-how-to-deal-with-them
This is the next installment of our series by Ayooluwa Isaiah that explains features in Go so developers can compare them to Ruby or whatever other language.
In the previous article in this series, we had an extensive discussion on the Go
net/http
package and how it can be used for production-ready web applications.
We focused mostly on the routing aspect and other quirks and features of the
http.ServeMux
type.
This article will close out the discussion on ServeMux
by demonstrating how
middleware functions can be implemented with the default router and introducing
other standard library packages that are sure to come in handy when developing
web services with Go.
https://www.honeybadger.io/blog/ruby-to-go-4/
Random fake data and struct generator for Go.
faker.SetSeed(622)
// Define a new builder
colorBuilder := func(params ...string) (interface{}, error) {
return faker.Pick("Red", "Yellow", "Blue", "Black", "White"), nil
}
// Register a new builder named "color" for string type
err := faker.RegisterBuilder("color", "string", colorBuilder)
if err != nil {
panic(err)
}
type Animal struct {
Name string `faker:"username"`
Color string `faker:"color"` // Use custom color builder
}
type Person struct {
FirstName string `faker:"firstName"` // Any available function case insensitive
LastName *string `faker:"lastName"` // Pointer are also supported
Age int `faker:"intinrange(0,120)"` // Can call with parameters
UUID string `faker:"uuid;unique"` // Guarantees a unique value
Number int `faker:"-"` // Skip this field
Code string // No tag to use default builder for this field type
Pet Animal // Recursively fill this struct
Nicknames []string `faker:"username;len=3"` // Build an array of size 3 using faker.Username function
Extra map[string]string `faker:"stringWithSize(3);len=2"` // map are supported
}
p := Person{}
err = faker.Build(&p)
if err != nil {
panic(err)
}
fmt.Println(p.FirstName)
fmt.Println(*p.LastName)
fmt.Println(p.Age)
fmt.Println(p.UUID)
fmt.Println(p.Number)
fmt.Println(p.Code)
fmt.Println(p.Pet.Name)
fmt.Println(p.Pet.Color)
fmt.Println(len(p.Nicknames))
fmt.Println(p.Nicknames[0])
fmt.Println(p.Nicknames[1])
fmt.Println(p.Nicknames[2])
fmt.Println(p.Extra)
// Output: Wilber
// Gutkowski
// 25
// ff8d6917-b920-46e6-b1be-dc2d48becfcb
// 0
// z
// honegger
// Red
// 3
// teagan
// polypeptide
// chinfest
// map[70w:3F6 gQS:isq]
One of the nice things about Faker is that it can also be used as a factory
library. In fact when we call the faker.Build
function if a value is not
zero then it is not modified, leaving the original value. This allows you to
create factory functions very easily:
faker.SetSeed(623)
type User struct {
Username string `faker:"username"`
Email string `faker:"email"`
Country string `faker:"CountryAlpha2"`
}
italianUserFactory := func() *User {
u := &User{Country: "IT"}
faker.Build(u)
return u
}
italianUser := italianUserFactory()
fmt.Println(italianUser)
// Output: &{spicule [email protected] IT}
When you're deciding on a technology to use for your project, it helps to have a broad understanding of your options. You may be tempted to build a web service in Go for performance reasons - but what would that code actually look like? How would it compare to languages like Ruby or JS? In this article, Ayooluwa Isaiah gives us a guided tour through the building blocks of go web services so you'll be well-informed. https://www.honeybadger.io/blog/go-web-services/
When you're evaluating a language for your next project, few things are more important than available third-party libraries and the package manager that ties them together. While early versions of Go lacked a package manager, they've made up for lost time. In this article, Ayooluwa Isaiah introduces us to Go's module ecosystem to help us decide if Go is "a go" for our next project. https://www.honeybadger.io/blog/golang-go-package-management/
These days fewer and fewer web developers get to specialize in a single language like Ruby. We use different tools for different jobs. In this article, Ayooluwa Isaiah argues that Go is the perfect complement to Ruby. The developer who knows both is in a great position to handle almost any back-end challenge. https://www.honeybadger.io/blog/rubyist-learn-go/