Go Community Linklog

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!


Go: comandos CLI, parte 1 (pt_BR)

Parte 1 de 3 onde esclareço o funcionamento dos comandos presentes na ferramenta CLI go.

http://devdrops.me/posts/go-comandos-cli-parte-1/

 Davi Marcondes Moreira

Import Cycles in Golang and How to Deal with them

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

 Jogendra

Web Development in Go: Middleware, Templating, Databases & Beyond

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/

 Ben Findley

Faker: random fake data and struct generator for Go. #faker @pioz

Random fake data and struct generator for Go.

https://github.com/pioz/faker

  • More than 100 generator functions
  • Struct generator
  • Unique data generator
  • Builtin types support
  • Easily customizable
  • Zero dependencies
  • Recursive infinite loop detector
  • Benchmarks (coming soon)

Struct Builder Example

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]

Factory

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

A Gentle Introduction to Web Services With Go

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/

 Ben Findley

Evaluating Go's Package Management and Module Systems

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/

 Ben Findley

Why Rubyists Should Consider Learning Go

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/

 Ben Findley

Debugging Go Applications using Delve

 

Logging in Go: Choosing a System and Using it

Go has built-in features to make it easier for programmers to implement logging. Third parties have also built additional tools to make logging easier. What's the difference between them? Which should you choose? In this article Ayooluwa Isaiah describes both of these and discusses when you'd prefer one over the other. https://www.honeybadger.io/blog/golang-logging/

 Ben Findley

Using Prometheus to collect metrics from Golang applications

In this post, I will talk about a very important feature in the complex projects we work with daily: metrics. Among the various solutions on the market for this purpose, one that has gained more prominence is the duo Prometheus + Grafana.

https://dev.to/codenation/using-prometheus-to-collect-metrics-from-golang-applications-35gc

 Elton Minetto

Golangflow.io - ANNOUNCEMENT

Hello Everyone!

Thank you for contributing to Golangflow.io, all the amazing content. Over the next few weeks, I will be migrating this site to Google Cloud Run in GCP and deploying a few new features. Hopefully, you won't notice the migration :)

 Brian Scott

Go Packages Tutorial for Go Modules

 

How To Check File Exists Using Golang

This golang tutorial help to check the file name is exist or not into the folders.We can pass pattern that will match filename into the target folders.

https://www.golanglearn.com/how-to-check-file-exists-using-golang/

 Adam

https://www.golanglearn.com/golang-maps-uses-and-example/

In this tutorial, we’ll learn how to use Golang’s built-in map type. map.The map is an unordered collection of key-value pairs.The keys are unique within a map while the values may not be.

https://www.golanglearn.com/golang-maps-uses-and-example/

 Adam

Beyond v1.0.0

Hey guys,

I would like to share with you that Beyond v1.0.0 is out.

Beyond is a Go tool that will drive you to the AOP world!

http://wesovilabs.com/beyond AOP http://wesovilabs.github.io/beyond

Hope you enjoy it!

 Iván Corrales Solera

Go for the REST @jsTamer21k @gobuffalo_io

Buffalo comes with a uniform and consistent structure for web applications in Go, follows best practives of Go web development and covers the full lifecycle from development to production. Learn how to build a RESTful web application in Go using the buffalo framework. https://dev.to/remast/go-for-the-rest-1jp9

 Jan Stamer

Deploy a Buffalo App to Heroku

Deploy a Buffalo App to Heroku from Antonio Pagano.

A lot of things have changed in the Buffalo ecosystem since my last post on how to deploy to Heroku from Gitlab.

Indeed, everything has changed since I posted how to deploy from gitlab repo into Heroku with the birth of the buffalo-heroku plugin. In this post I will try and describe how to use it to deploy your buffalo app to Heroku.

 Brian Scott



API gateway examples with Traefik, Ambassador and Envoy

API gateway acts as a reverse proxy, routing API requests from clients to services. Usually it also performs authentication and rate limiting, so the services behind the gate don't have to. Check out short tutorials of Ambassador and Traefik that aim to tackle the problem, also there is Envoy example in https://github.com/marselester/apigate.

 Marsel Mavletkulov