Skip to content
gqlxj1987's Blog
Go back

Golang Tips

Edit page

Go Datastructures slices

go datastructures

diff between c arrays and go array

diff between go array and slice

slice is a collection of data in contiguous blocks of memory

Nil slice: var slice[] int , empty slice slice:=make([]int, 0) or slice:=[]int{}

growing slice -> like java list, factor to grow? no..

growing in slice

slice append - third index

func main() {
	k:=make([]int,0)
	
	k = append(k, 1)
	k = append(k, 2)
	k = append(k, 3)
	k = append(k, 4)
	k = append(k, 5)
	k = append(k, 6)
	
	t:=k[2:3:3]
	
	fmt.Println(k)
	fmt.Println(t)
	
	t = append(t, 7)
	
	fmt.Println(k)
	fmt.Println(t)
}

the reuslt:

[1 2 3 4 5 6]
[3]
[1 2 3 4 5 6]
[3 7]

notice the detach operation

but what the meaning of the capacity?

passing slices to functions

since only the pointer to the backing array is passed, this is very efficient. whether the size of the backing array is 10 or one million only 24 bytes are passed to function

RFC: Apache Beam Go SDK design

RFC: Apache Beam Go SDK design

Apache Beam

is an advanced unified programming model, implement batch and streaming data processing jobs that run on any execution engine

weak point:

strong point:

key design points

examples

model representation
Transforms

Edit page
Share this post on:

Previous Post
毫秒级实时排序
Next Post
Git Flow