Format types in golang



%s  dùng để format cho String: 
fmt.Printf("%s\n", "\"string\"")

%c dùng để format 1 số nguyên về kiểu ký tự
fmt.Printf("%c\n", 33)

%v dùng để format một struct, hoặc số, hoặc boolean, hoặc con trỏ về đúng kiểu giá trị của nó



%T dùng để xác đinh type của kiểu dữ liệu
fmt.Printf("%T\n", p)

fmt.Printf("%t\n", true)


%d dùng để in giá trị số nguyên

%f dùng để in số thực
fmt.Printf("%.2f\n", 78.123123)
































Comments

Popular posts from this blog

Fixing the DeepSpeed Import Error While Fine-Tuning the Qwen Model

Amazon Linux 2023 - User data configuration for launch templates to connect to the EKS cluster

How to create ISM policy and rotate logs in opensearch