We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 334653a + 1570388 commit 12530e3Copy full SHA for 12530e3
examples/gocollective/print-struct-variables/Taskfile.yml
@@ -0,0 +1,6 @@
1
+version: "3"
2
+
3
+tasks:
4
+ run:
5
+ cmds:
6
+ - go run main.go
examples/gocollective/print-struct-variables/main.go
@@ -0,0 +1,31 @@
+// Stackoverflow Go Collective example
+//
+// How to print struct variables in console
+// URL
+// - 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
28
29
+}) {
30
+ fmt.Printf("%+v\n", *o)
31
0 commit comments