Created
April 24, 2022 10:55
-
-
Save tio-iis/2d8184a0b45bbe52e4d834c2e5e1775c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
//今までのプログラミング(型推論を利用している) | |
//str := "tio" | |
//fmt.Println(str) | |
//型推論なしの変数宣言 | |
//var atai string = "tio" | |
//fmt.Println(atai) | |
//stringのポインタを宣言し、変数 atai のアドレスを代入する | |
//var pointer *string = &atai | |
//ポインタに格納されているアドレスを出力する。 | |
//fmt.Println(pointer) | |
//ポインタに格納されているアドレスの値を出力する。 | |
//fmt.Println(*pointer) | |
u := &User{ | |
name: "tio", | |
} | |
fmt.Println(u.name) | |
echo(u) | |
} | |
type User struct { | |
name string | |
} | |
func echo(u *User) { | |
fmt.Println("echo: " + u.name) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment