Giter VIP home page Giter VIP logo

go-tips's Introduction

GO-tips

a variable declare inside a loop, will be a new instance at each iteration
Il y a des gestionnaires de projet
External function call with a capital letter : math.Pi

go mod init

books to read :

Concurrency in Go: Tools and Techniques for Developers
100 Go Mistakes and How to Avoid Them: Common Go Mistakes


conference de rob pike (google)

golangci-lint


Good site to learn syntax :
1. a tour of go
2. go by exemple
3. effective go
4. lets go + lets go further (web dev)
5. https://exercism.org/tracks/go/
6. https://github.com/inancgumus/learngo

Questions

difference channel et atomic
thread vs semaphore in go
fork in go and why would i want that
go warps
auto formating de go
go wire lib

Print

fmt.Print: Affiche les arguments sur la sortie standard.
fmt.Println: Comme fmt.Print, mais ajoute un saut de ligne à la fin.
fmt.Printf: Permet de formater les chaînes de caractères comme avec printf en C.
fmt.Sprint: Renvoie une chaîne de caractères au lieu de l'afficher.
fmt.Sprintln: Comme fmt.Sprint, mais ajoute un saut de ligne.
fmt.Sprintf: Comme fmt.Printf, mais renvoie une chaîne de caractères au lieu de l'afficher.

Slice

Une tranche a trois composants : un pointeur vers le tableau sous-jacent, une longueur et une capacité.

Ressources

https://www.reddit.com/r/golang/comments/lvwu45/go_and_freelance_work/

projects

Todo application
Chat Application
CLI
Microservices which communicate using gRPC
Containerizing a Go application
Create a blogging website
Webscraper using net/http and goquery package
Rate limiter
Email Template generator using template package
cloud

Methode

Methods and pointer indirection
Comparing the previous two programs, you might notice that functions with a pointer argument must take a pointer:

var v Vertex
ScaleFunc(v, 5)  // Compile error!
ScaleFunc(&v, 5) // OK
while methods with pointer receivers take either a value or a pointer as the receiver when they are called:

var v Vertex
v.Scale(5)  // OK
p := &v
p.Scale(10) // OK
For the statement v.Scale(5), even though v is a value and not a pointer, the method with the pointer receiver is called automatically. That is, as a convenience, Go interprets the statement v.Scale(5) as (&v).Scale(5) since the Scale method has a pointer receiver.

The equivalent thing happens in the reverse direction.

Functions that take a value argument must take a value of that specific type:

var v Vertex
fmt.Println(AbsFunc(v))  // OK
fmt.Println(AbsFunc(&v)) // Compile error!
while methods with value receivers take either a value or a pointer as the receiver when they are called:

var v Vertex
fmt.Println(v.Abs()) // OK
p := &v
fmt.Println(p.Abs()) // OK
In this case, the method call p.Abs() is interpreted as (*p).Abs().

go-tips's People

Contributors

beorlor avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.