Skip to content

Instantly share code, notes, and snippets.

@tmrtmhr
Last active March 15, 2017 06:06
Show Gist options
  • Save tmrtmhr/d17e3b718dc873661188f14b406b1bba to your computer and use it in GitHub Desktop.
Save tmrtmhr/d17e3b718dc873661188f14b406b1bba to your computer and use it in GitHub Desktop.
GO言語(golang)における各リテラルの型を表示する
package main
import (
"fmt"
)
func main() {
fmt.Printf("%T\n", 123) // 整数リテラル
fmt.Printf("%T\n", 123.0) // 浮動小数リテラル
fmt.Printf("%T\n", "文字列") // 文字列リテラル
fmt.Printf("%T\n", 'ä') // ルーンリテラル
fmt.Printf("%T\n", 0i) //虚数リテラル
fmt.Printf("%T\n", true) // boolリテラル
}
// 出力:
// int
// float64
// string
// int32
// complex128
// bool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment