Last active
June 8, 2021 17:15
-
-
Save r002/651043e3e72bc531e89a7eebecc7f3e5 to your computer and use it in GitHub Desktop.
Go Tutorial: Anonymous Structs
This file contains hidden or 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
| func TestHello(t *testing.T) { | |
| testcase1 := &struct { | |
| arg string | |
| want string | |
| }{ | |
| "original arg val", | |
| "original want val", | |
| } | |
| fmt.Println(">> testcase1.arg:", testcase1.arg) | |
| testcase2 := testcase1 | |
| testcase1.arg = "changed arg val" | |
| fmt.Println(">> testcase2.arg:", testcase2.arg) | |
| } | |
| // Output: | |
| >> testcase1.arg: original arg val | |
| >> testcase2.arg: changed arg val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment