Skip to content

Commit a28d1b5

Browse files
authored
Merge pull request #760 from devlights/add-result-in-example
2 parents aa8426d + ec1a009 commit a28d1b5

File tree

8 files changed

+156
-9
lines changed

8 files changed

+156
-9
lines changed

examples/basic/strconvs/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
このディレクトリには以下のサンプルがあります。
44

5-
| file | example name | note |
6-
|------------------------------|-----------------------------------|-------------------------------------------------|
7-
| hex\_to\_dec.go | strconvs\_hex\_to\_dec | 16進数文字列を10進数に変換するサンプルです. |
8-
| bin\_to\_dec.go | strconvs\_bin\_to\_dec | 2進数文字列を10進数に変換するサンプルです. |
9-
| dec\_to\_dec.go | strconvs\_dec\_to\_dec | 10進数文字列を10進数に変換するサンプルです. |
10-
| hex\_to\_bin.go | strconvs\_hex\_to\_bin | 16進数文字列を2進数文字列に変換するサンプルです. |
11-
| bin\_to\_hex.go | strconvs\_bin\_to\_hex | 2進数文字列を16進数文字列に変換するサンプルです. |
12-
| parseint\_tips\_bitsize.go | strconvs\_parseint\_tips\_bitsize | strconv.ParseInt() の第3引数 bitSize を指定する際のTipsです。 |
13-
| parseint\_tips\_basevalue.go | strconvs\_parseint\_tips\_base | strconv.ParseInt() の第2引数 base を指定する際のTipsです。 |
5+
| file | example name | note |
6+
| -------------------------- | ------------------------------ | -------------------------------------------------------------- |
7+
| hex_to_dec.go | strconvs_hex_to_dec | 16進数文字列を10進数に変換するサンプルです. |
8+
| bin_to_dec.go | strconvs_bin_to_dec | 2進数文字列を10進数に変換するサンプルです. |
9+
| dec_to_dec.go | strconvs_dec_to_dec | 10進数文字列を10進数に変換するサンプルです. |
10+
| hex_to_bin.go | strconvs_hex_to_bin | 16進数文字列を2進数文字列に変換するサンプルです. |
11+
| bin_to_hex.go | strconvs_bin_to_hex | 2進数文字列を16進数文字列に変換するサンプルです. |
12+
| parseint_tips_bitsize.go | strconvs_parseint_tips_bitsize | strconv.ParseInt() の第3引数 bitSize を指定する際のTipsです。 |
13+
| parseint_tips_basevalue.go | strconvs_parseint_tips_base | strconv.ParseInt() の第2引数 base を指定する際のTipsです。 |

examples/basic/strconvs/bin_to_dec.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,24 @@ func BinToDec() error {
3838
}
3939

4040
return nil
41+
42+
/*
43+
$ task
44+
task: [build] go build .
45+
task: [run] ./try-golang -onetime
46+
47+
ENTER EXAMPLE NAME: strconvs_bin_to_dec
48+
49+
[Name] "strconvs_bin_to_dec"
50+
[original] 11111111
51+
[parsed ] 255
52+
--------------------------------------------------
53+
[original] 11011110101011011011111011101111
54+
[parsed ] 3735928559
55+
--------------------------------------------------
56+
57+
58+
[Elapsed] 56.51µs
59+
*/
60+
4161
}

examples/basic/strconvs/bin_to_hex.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,26 @@ func BinToHex() error {
4343
}
4444

4545
return nil
46+
47+
/*
48+
$ task
49+
task: [build] go build .
50+
task: [run] ./try-golang -onetime
51+
52+
ENTER EXAMPLE NAME: strconvs_bin_to_hex
53+
54+
[Name] "strconvs_bin_to_hex"
55+
[original] 0b11111111
56+
[parsed ] 255
57+
[conveted] ff
58+
--------------------------------------------------
59+
[original] 0b11011110101011011011111011101111
60+
[parsed ] 3735928559
61+
[conveted] deadbeef
62+
--------------------------------------------------
63+
64+
65+
[Elapsed] 1.44571ms
66+
*/
67+
4668
}

examples/basic/strconvs/dec_to_dec.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,28 @@ func DecToDec() error {
3636
output.Stdoutl("[atoi ]", atoi(v))
3737
output.StderrHr()
3838
}
39+
3940
return nil
41+
42+
/*
43+
$ task
44+
task: [build] go build .
45+
task: [run] ./try-golang -onetime
46+
47+
ENTER EXAMPLE NAME: strconvs_dec_to_dec
48+
49+
[Name] "strconvs_dec_to_dec"
50+
[original] 255
51+
[parseInt] 255
52+
[atoi ] 255
53+
--------------------------------------------------
54+
[original] 3735928559
55+
[parseInt] 3735928559
56+
[atoi ] 3735928559
57+
--------------------------------------------------
58+
59+
60+
[Elapsed] 56.19µs
61+
*/
62+
4063
}

examples/basic/strconvs/hex_to_bin.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,26 @@ func HexToBin() error {
4343
}
4444

4545
return nil
46+
47+
/*
48+
$ task
49+
task: [build] go build .
50+
task: [run] ./try-golang -onetime
51+
52+
ENTER EXAMPLE NAME: strconvs_hex_to_bin
53+
54+
[Name] "strconvs_hex_to_bin"
55+
[original] 0xff
56+
[parsed ] 255
57+
[conveted] 11111111
58+
--------------------------------------------------
59+
[original] 0xDEADBEEF
60+
[parsed ] 3735928559
61+
[conveted] 11011110101011011011111011101111
62+
--------------------------------------------------
63+
64+
65+
[Elapsed] 96.96µs
66+
*/
67+
4668
}

examples/basic/strconvs/hex_to_dec.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,26 @@ func HexToDec() error {
3333
output.Stdoutl("[parsed ]", parsed)
3434
output.StdoutHr()
3535
}
36+
3637
return nil
38+
39+
/*
40+
$ task
41+
task: Task "build" is up to date
42+
task: [run] ./try-golang -onetime
43+
44+
ENTER EXAMPLE NAME: strconvs_hex_to_dec
45+
46+
[Name] "strconvs_hex_to_dec"
47+
[original] ff
48+
[parsed ] 255
49+
--------------------------------------------------
50+
[original] deadbeef
51+
[parsed ] 3735928559
52+
--------------------------------------------------
53+
54+
55+
[Elapsed] 91.49µs
56+
*/
57+
3758
}

examples/basic/strconvs/parseint_tips_basevalue.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,27 @@ func ParseIntTipsBaseValue() error {
4949
}
5050

5151
return nil
52+
53+
/*
54+
$ task
55+
task: [build] go build .
56+
task: [run] ./try-golang -onetime
57+
58+
ENTER EXAMPLE NAME: strconvs_parseint_tips_base
59+
60+
[Name] "strconvs_parseint_tips_base"
61+
[original] 0b11111111
62+
[parsed ] 255
63+
--------------------------------------------------
64+
[original] 0o377
65+
[parsed ] 255
66+
--------------------------------------------------
67+
[original] 0xff
68+
[parsed ] 255
69+
--------------------------------------------------
70+
71+
72+
[Elapsed] 52.669µs
73+
*/
74+
5275
}

examples/basic/strconvs/parseint_tips_bitsize.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,20 @@ func ParseIntTipsBitSize() error {
3737
output.Stdoutl("[parsed ]", int(parsed))
3838

3939
return nil
40+
41+
/*
42+
$ task
43+
task: [build] go build .
44+
task: [run] ./try-golang -onetime
45+
46+
ENTER EXAMPLE NAME: strconvs_parseint_tips_bitsize
47+
48+
[Name] "strconvs_parseint_tips_bitsize"
49+
[original] ff
50+
[parsed ] 255
51+
52+
53+
[Elapsed] 21.09µs
54+
*/
55+
4056
}

0 commit comments

Comments
 (0)