GO fmt.Sprintf

Mario tsai
Dec 24, 2022

--

self-learning note

int -> %d

stinrg-> %s

func foo(a int, b string) string { 
return fmt.Sprintf("%d %s", a, b)
}

*string -> %p

var ptr *string  // 宣告一個指向字串的指標變數ptr

fmt.Printf("%p \n", ptr) // 印出: 0x0 (尚未指派記憶體位置)

--

--

Mario tsai
Mario tsai

Written by Mario tsai

Major in physical education. Football referee. And high interest in looking the world through the numbers.