Skip to content

Commit 12530e3

Browse files
authored
Merge pull request #568 from devlights/add-go-collective-examples
2 parents 334653a + 1570388 commit 12530e3

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: "3"
2+
3+
tasks:
4+
run:
5+
cmds:
6+
- go run main.go
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Stackoverflow Go Collective example
2+
//
3+
// How to print struct variables in console
4+
//
5+
// URL
6+
// - https://stackoverflow.com/questions/24512112/how-to-print-struct-variables-in-console
7+
//
8+
// REFERENCES
9+
// - https://pkg.go.dev/fmt@latest
10+
package main
11+
12+
import "fmt"
13+
14+
func main() {
15+
o := struct {
16+
Id int
17+
Value string
18+
}{1, "hello world"}
19+
20+
fmt.Printf("[%%v ] %v\n", o)
21+
fmt.Printf("[%%+v] %+v\n", o)
22+
23+
fn(&o)
24+
}
25+
26+
func fn(o *struct {
27+
Id int
28+
Value string
29+
}) {
30+
fmt.Printf("%+v\n", *o)
31+
}

0 commit comments

Comments
 (0)