hhow09 / gobyexample Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://hhow09.github.io/gobyexample/
Home Page: https://hhow09.github.io/gobyexample/
func (v Value) CanSet() bool
CanSet reports whether the value of v can be changed. A Value can be
changed only if it is addressable and was not obtained by the use of
unexported struct fields. If CanSet returns false, calling Value.Set or any
type-specific setter (e.g., Value.SetBool, Value.SetInt) will panic.
Although there are infinitely many types, there are only a finite number of kinds of type: the basic types Bool, String and all the numbers; the aggregate types Array
and Struct
, the reference types Chan
, Func
, Ptr
, Slice
and Map
; interface
types; and finally Invalid, meaning no value at all (The zero value of a reflect.Value has kind Invalid).
如果range over slice時對slice作改動,是否會改動slice ?
range over slice will copy the original value.
how to compare 2 struct value ?
reflect.DeepEqual
how to verify that struct actually implement a Interface ?
var _ Interface = (*Struct_Should_Implement)(nil)
convert []byte
to string
是否會造成 copy ?
[]byte
is mutableModifying map while iterating over it ?
How to check if a slice is sorted ?
marshal json what is the result ?
type J struct {
a string
b string `json:"B"`
C string
D string `json:"DD"`
}
j := J{
a: "1",
b: "2",
C: "3",
D: "4",
}
fmt.Printf("j = %+v\n", j)
make vs new
can we address the map ?
m := make(map[string]int)
fmt.Println(&m["qcrao"])
// cannot take the address of m["qcrao"]
use case of tag
fmt.Printf
with %v
%+v
%#v
type animal struct {
name string
age int
}
a := animal{name: "cat", age: 2}
fmt.Printf("%v\n", a) // {cat 2}
fmt.Printf("%+v\n", a) // {name:cat age:2}
fmt.Printf("%#v\n", a) // main.animal{name:"cat", age:2}
nil
channelhmap
struct with pointer buckets
to buckets array of 2^B
buckets.bmap
struct with 8 buckets, each bucket stores an key value pairserver.listenAndServe()
in backgroundsyscall.SIGTERM
)A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.