mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-26 14:56:02 +03:00
play adress
This commit is contained in:
parent
52811552c6
commit
d6a1cbd47f
40
playground/basic/address_test.go
Normal file
40
playground/basic/address_test.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package basic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPrintAddress(t *testing.T) {
|
||||||
|
var a int
|
||||||
|
fmt.Printf("%T, %v, %p \n", a, a, &a)
|
||||||
|
passByVariable(a)
|
||||||
|
passByPointer(&a)
|
||||||
|
}
|
||||||
|
|
||||||
|
func passByVariable(a int) {
|
||||||
|
fmt.Printf("%T, %v, %p \n", a, a, &a)
|
||||||
|
}
|
||||||
|
|
||||||
|
func passByPointer(a *int) {
|
||||||
|
fmt.Printf("%T, %v, %p \n", a, a, &a)
|
||||||
|
fmt.Printf("%T, %v, %p \n", *a, *a, &*a)
|
||||||
|
}
|
||||||
|
|
||||||
|
type robot struct{}
|
||||||
|
|
||||||
|
func TestStructAddress(t *testing.T) {
|
||||||
|
var a robot
|
||||||
|
fmt.Printf("%T, %v, %p \n", a, a, &a)
|
||||||
|
passStructByVariable(a)
|
||||||
|
passStructByPointer(&a)
|
||||||
|
}
|
||||||
|
|
||||||
|
func passStructByVariable(a robot) {
|
||||||
|
fmt.Printf("%T, %v, %p \n", a, a, &a)
|
||||||
|
}
|
||||||
|
|
||||||
|
func passStructByPointer(a *robot) {
|
||||||
|
fmt.Printf("%T, %v, %p \n", a, a, &a)
|
||||||
|
fmt.Printf("%T, %v, %p \n", *a, *a, &*a)
|
||||||
|
}
|
@ -30,7 +30,8 @@ func TestUploadFormFile(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if _, err = io.Copy(formFileWriter, bytes.NewReader(yamlFile)); err != nil {
|
_, err = io.Copy(formFileWriter, bytes.NewReader(yamlFile))
|
||||||
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
writer.Close()
|
writer.Close()
|
||||||
|
Loading…
Reference in New Issue
Block a user