LoginSignup
0
0

More than 1 year has passed since last update.

【自己学習】Go言語を学ぶ(4)

Posted at

公式チュートリアルから基本を学ぶ
https://go-tour-jp.appspot.com/list

Basic types(基本型)

基本型についてまとめ

  • 論理値型
    bool ()

  • 文字列型
    string

  • 数値型

    • 符合付き整数型
      int int8 int16 int32 int64
    • 符合なし整数型
      uint uint8 uint16 uint32 uint64 uintptr
  • byte型
    byte // uint8 の別名

  • rune型(Unicodeの番号を10進数に変換したものを返す)
    rune // int32 の別名
    // Unicode のコードポイントを表す

  • 浮動小数点型
    float32 float64

  • 複素数型
    complex64 complex128

論理値型

サンプルコード

package main

import "fmt"

func main() {
  var b bool

  b = true
  b = false
  b = trie || false
  fmt.Println(b)
}

数値型

サンプルコード

package main

import "fmt"

func main() {
  var i int = 12345
  var i64 int64 = int64(i)

  fmt.Println(i64)
}

文字列型

サンプルコード

package main

import "fmt"

func main() {
  var str string
  str = "A"
  str = str + "B"
  str += "C"

  fmt.Println(str)
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0