Introduction
-
From c++ by google c++ author will convert to exe
-
go get githublink→ to download pkg and put under folder pkg
-
it has main function to run
go run filename.go
Data types
-
string, bool, int, byte , float32 ,float64, arrays
-
using var keyword and const → to not reassign
-
var name string = “d” (if directly assing vaule we don’t need to mention the data type)
-
var age = 23
-
name := “test” → this kind of declaration we can be only defined inside function
-
name,email := “test”,”email”
-
Arrays
-
Struct
-
Map
Function
- Arguments are passed as copy use pointer for call by reference
Pointers
Conditions
Loops
Runes
Go’s runes are used to represent single characters. ‘A’ →65 Runes are kept as numeric codes
If you declare a variable without assigning it a value, that variable will contain the zero value
short variable declaration
instead of explicitly declaring the type of the variable and later assigning to it with = , you do both at once using := .
If the name of a variable, function, or type begins with a capital letter, it is considered exported and can be accessed from packages outside the current one.
Conversions
Only same type can be do math operation float and int cannot to convert
- int(3.0)
- float64(9)
Packages
Go tools look for package code in a special directory (folder) on your computer called the workspace. By default, the workspace is a directory named go in the current user’s home directory.
The workspace directory contains three subdirectories
- bin, which holds compiled binary executable programs.
- pkg, which holds compiled binary package files.
- src, which holds Go source code.
others
Split your application into components written as regular Go interfaces. Don’t fuss with any networking or serialization code. Focus on your business logic. (https://serviceweaver.dev/)
- Go routine → make threads simple
- channel