Skip to content

Commit 14d013c

Browse files
authored
Merge pull request #698 from devlights:add-result-in-examples
Add result in examples (examples/basic/convert)
2 parents 0c101bf + dc8078a commit 14d013c

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

examples/basic/convert/int_to_str.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,20 @@ func IntToStr() error {
2323
output.Stdoutf("[float to str]", "%[1]v(%[1]T) --> %[2]q(%[2]T)\n", f, s)
2424

2525
return nil
26+
27+
/*
28+
$ task
29+
task: [build] go build .
30+
task: [run] ./try-golang -onetime
31+
32+
ENTER EXAMPLE NAME: convert_int_to_str
33+
34+
[Name] "convert_int_to_str"
35+
[int to str] 100(int) --> "100"(string)
36+
[float to str] 12.345(float32) --> "12.345"(string)
37+
38+
39+
[Elapsed] 25.03µs
40+
*/
41+
2642
}

examples/basic/convert/strslice_to_ifslice.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,23 @@ func StringSliceToInterfaceSlice() error {
118118
output.Stdoutl("[is2]", is2)
119119

120120
return nil
121+
122+
/*
123+
$ task
124+
task: Task "build" is up to date
125+
task: [run] ./try-golang -onetime
126+
127+
ENTER EXAMPLE NAME: convert_string_slice_to_interface_slice
128+
129+
[Name] "convert_string_slice_to_interface_slice"
130+
[ifSlice] [hello world]
131+
[intSlice] [1 2]
132+
[s --> i] helloworld
133+
[i2] 0
134+
[is2] [1 2 3 4]
135+
136+
137+
[Elapsed] 83.39µs
138+
*/
139+
121140
}

examples/basic/convert/struct_to_str.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,20 @@ func StructToStr() error {
4343
fn(y)
4444

4545
return nil
46+
47+
/*
48+
$ task
49+
task: [build] go build .
50+
task: [run] ./try-golang -onetime
51+
52+
ENTER EXAMPLE NAME: convert_struct_to_str
53+
54+
[Name] "convert_struct_to_str"
55+
[struct to str] id=100,name=sts(convert.sts) --> "id=100,name=sts"(string)
56+
[struct to str] ¥1000(convert.yen) --> "¥1000"(string)
57+
58+
59+
[Elapsed] 55.5µs
60+
*/
61+
4662
}

0 commit comments

Comments
 (0)