This repo contains my notes on working with Go and computer systems.
BSD-2-CLAUSE License
This repo contains my notes on work with Go and computer systems
Language Specification
Syntax
Struct: Declare_Initialize | Name And Anonymous type Field | Field Function| Iterate Field Name And Value | Selector and Promoted | Method Set
Function: Initialization | argument | multiple returns | named return
Data Structures
Decoupling
Dependency management Go Modules
Error Handling
Context
Concurrency LearnConcurrency
Diagnostics Profiling
Testing
Design Pattern Design Patterns | javatpoint
Crypto
databases
Awesome Go
Docs
Interview
defer
called?
It was called according the consuming sequence of stack. That is to say, the first
defer
clause will be invoked as the last.
defer
and panic
which is run first?
First
defer
, thenpanic
.
new()
and make()
?
For
new
function, it returns pointer. It is used when initiate struct.Make
is mostly used when initiate slice, map and channel.
append()
receive pointer as parameter?
No.
No.
When passing value, it will create a new copy. For pointer, it will pass the value itself.
str := "hello", str[1] = 'a'
Is the string gonna modified?
No. Because the string is a constant.
string
?
No. But we can assign nil to
*string
map
and range
is executed by sequence?
No.
==
?
No.
No. &Vector{} , new(Vector) is the same, one thing to note: new() is the only way to get a pointer to an unnamed integer or other basic type. You can write "p := new(int)" but you can't write "p := &int{0}".