User Tools

Site Tools


programming:golang

golang cheatsheet and notes

printf formatting verbs

  • %v - the default format for the value
  • %T - a Go-syntax representation of the type of the value
  • %t - the word true or false
  • %d - decimal integer
  • %b - binary format
  • %o - octal format
  • %x, %X - hexadecimal format
  • %f, %e, %E, %g, %G - floating-point numbers
  • %s - string format
  • %q - quoted string format
  • %p - pointer format
package main
 
import (
	"fmt"
)
 
func main() {
	name := "John"
	age := 30
	height := 1.75
 
	fmt.Printf("Name: %s\n", name)
	fmt.Printf("Age: %d\n", age)
	fmt.Printf("Height: %.2f\n", height)
}
programming/golang.txt · Last modified: 2023/03/11 02:09 by kamaradski