Skip to content

Commit 9fd838c

Browse files
authored
Merge pull request #736 from devlights/add-result-in-example
2 parents 31c33fc + eee2745 commit 9fd838c

File tree

10 files changed

+164
-16
lines changed

10 files changed

+164
-16
lines changed

examples/basic/mutex/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# サンプルリスト
1+
# サンプルリスト
22

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

5-
| file | example name | note |
6-
|--------------------------|-------------------|----------------------------|
7-
| nomutex/nomutex.go | mutex\_nomutex | Mutexを利用しない場合のサンプルです. |
8-
| usemutex/usemutex.go | mutex\_usemutex | Mutexを利用した場合のサンプルです. |
9-
| usechannel/usechannel.go | mutex\_usechannel | Mutexの代わりにチャネルを利用したサンプルです. |
5+
| file | example name | note |
6+
| ------------------------ | ---------------- | ---------------------------------------------- |
7+
| nomutex/nomutex.go | mutex_nomutex | Mutexを利用しない場合のサンプルです. |
8+
| usemutex/usemutex.go | mutex_usemutex | Mutexを利用した場合のサンプルです. |
9+
| usechannel/usechannel.go | mutex_usechannel | Mutexの代わりにチャネルを利用したサンプルです. |

examples/basic/mutex/nomutex/nomutex.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,20 @@ func NoMutex() error {
5454
output.Stdoutl("[balance]", balance)
5555

5656
return nil
57+
58+
/*
59+
$ task
60+
task: Task "build" is up to date
61+
task: [run] ./try-golang -onetime
62+
63+
ENTER EXAMPLE NAME: mutex_nomutex
64+
65+
[Name] "mutex_nomutex"
66+
[execCount] 20000
67+
[balance] 1310
68+
69+
70+
[Elapsed] 10.71242ms
71+
*/
72+
5773
}

examples/basic/mutex/usechannel/usechannel.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,20 @@ func UseChannel() error {
5858
output.Stdoutl("[balance]", <-balance)
5959

6060
return nil
61+
62+
/*
63+
$ task
64+
task: [build] go build .
65+
task: [run] ./try-golang -onetime
66+
67+
ENTER EXAMPLE NAME: mutex_usechannel
68+
69+
[Name] "mutex_usechannel"
70+
[execCount] 20000
71+
[balance] 1000
72+
73+
74+
[Elapsed] 26.932628ms
75+
*/
76+
6177
}

examples/basic/mutex/usemutex/usemutex.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,20 @@ func UseMutex() error {
6161
output.Stdoutl("[balance]", balance)
6262

6363
return nil
64+
65+
/*
66+
$ task
67+
task: [build] go build .
68+
task: [run] ./try-golang -onetime
69+
70+
ENTER EXAMPLE NAME: mutex_usemutex
71+
72+
[Name] "mutex_usemutex"
73+
[execCount] 20000
74+
[balance] 1000
75+
76+
77+
[Elapsed] 11.125079ms
78+
*/
79+
6480
}

examples/basic/network/README.md

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

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

5-
| file | example name | note |
6-
|-----------------------------------|-----------------------------------------|---------------------------------------------------------------|
7-
| ipaddress\_parse.go | network\_ipaddress\_parse | net.ParseIP() の サンプルです. |
8-
| ssh\_no\_privkey\_passphrase.go | network\_ssh\_no\_privkey\_passphrase | 秘密鍵のパスフレーズ無しのSSH接続サンプルです. |
9-
| ssh\_with\_privkey\_passphrase.go | network\_ssh\_with\_privkey\_passphrase | 秘密鍵のパスフレーズありのSSH接続サンプルです. |
10-
| ssh\_close\_after\_run.go | network\_ssh\_close\_after\_run | ssh.Run() を呼んだ後に ssh.Close() を呼ぶと io.EOF が返却されることを確認するサンプルです. |
11-
| http\_get.go | network\_http\_get | http.Get() の サンプルです. |
12-
| join\_host\_port.go | network\_join\_host\_port | JoinHostPort は、net.JoinHostPort のサンプルです |
13-
| split\_host\_port.go | network\_split\_host\_port | SplitJoinPort は、net.SplitHostPort のサンプルです |
14-
| lookup\_port.go | network\_lookup\_port | LookupPort は、 net.LookupPort() のサンプルです |
5+
| file | example name | note |
6+
| ------------------------------ | ----------------------------------- | ------------------------------------------------------------------------------------------ |
7+
| ipaddress_parse.go | network_ipaddress_parse | net.ParseIP() の サンプルです. |
8+
| ssh_no_privkey_passphrase.go | network_ssh_no_privkey_passphrase | 秘密鍵のパスフレーズ無しのSSH接続サンプルです. |
9+
| ssh_with_privkey_passphrase.go | network_ssh_with_privkey_passphrase | 秘密鍵のパスフレーズありのSSH接続サンプルです. |
10+
| ssh_close_after_run.go | network_ssh_close_after_run | ssh.Run() を呼んだ後に ssh.Close() を呼ぶと io.EOF が返却されることを確認するサンプルです. |
11+
| http_get.go | network_http_get | http.Get() の サンプルです. |
12+
| join_host_port.go | network_join_host_port | JoinHostPort は、net.JoinHostPort のサンプルです |
13+
| split_host_port.go | network_split_host_port | SplitJoinPort は、net.SplitHostPort のサンプルです |
14+
| lookup_port.go | network_lookup_port | LookupPort は、 net.LookupPort() のサンプルです |

examples/basic/network/http_get.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,20 @@ func HttpGet() error {
7979
}
8080

8181
return nil
82+
83+
/*
84+
$ task
85+
task: Task "build" is up to date
86+
task: [run] ./try-golang -onetime
87+
88+
ENTER EXAMPLE NAME: network_http_get
89+
90+
[Name] "network_http_get"
91+
recv bytes 173143
92+
http.get GitHub - devlights/try-golang: This is my TUTORIAL project for golang.
93+
94+
95+
[Elapsed] 448.931025ms
96+
*/
97+
8298
}

examples/basic/network/ipaddr_parse.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,21 @@ func IpAddressParse() error {
2222
}
2323

2424
return nil
25+
26+
/*
27+
$ task
28+
task: [build] go build .
29+
task: [run] ./try-golang -onetime
30+
31+
ENTER EXAMPLE NAME: network_ipaddress_parse
32+
33+
[Name] "network_ipaddress_parse"
34+
[OK] 127.0.0.1
35+
[NG] 127.0.01
36+
[NG] invalid
37+
38+
39+
[Elapsed] 47.1µs
40+
*/
41+
2542
}

examples/basic/network/join_host_port.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,22 @@ func JoinHostPort() error {
3535
}
3636

3737
return nil
38+
39+
/*
40+
$ task
41+
task: [build] go build .
42+
task: [run] ./try-golang -onetime
43+
44+
ENTER EXAMPLE NAME: network_join_host_port
45+
46+
[Name] "network_join_host_port"
47+
[JoinHostPort] :9999
48+
[JoinHostPort] 127.0.0.1:9999
49+
[JoinHostPort] localhost:9999
50+
[JoinHostPort] [::1]:9999
51+
52+
53+
[Elapsed] 18.86µs
54+
*/
55+
3856
}

examples/basic/network/lookup_port.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,29 @@ func LookupPort() error {
5050
}
5151

5252
return nil
53+
54+
/*
55+
$ task
56+
task: [build] go build .
57+
task: [run] ./try-golang -onetime
58+
59+
ENTER EXAMPLE NAME: network_lookup_port
60+
61+
[Name] "network_lookup_port"
62+
[LookupPort] serivce=ftp port=21
63+
[LookupPort] serivce=ssh port=22
64+
[LookupPort] serivce=telnet port=23
65+
[LookupPort] serivce=http port=80
66+
[LookupPort] serivce=pop3 port=110
67+
[LookupPort] serivce=imap port=143
68+
[LookupPort] serivce=https port=443
69+
[LookupPort] serivce=8888 port=8888
70+
[Err] service=-1 Err=address -1: invalid port
71+
[Err] service=65536 Err=address 65536: invalid port
72+
[Err] service=xdmcp Err=lookup tcp/xdmcp: Servname not supported for ai_socktype
73+
74+
75+
[Elapsed] 4.762829ms
76+
*/
77+
5378
}

examples/basic/network/split_host_port.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,28 @@ func SplitHostPort() error {
4242
}
4343

4444
return nil
45+
46+
/*
47+
$ task
48+
task: [build] go build .
49+
task: [run] ./try-golang -onetime
50+
51+
ENTER EXAMPLE NAME: network_split_host_port
52+
53+
[Name] "network_split_host_port"
54+
[Original ] :9999
55+
[SplitHostPort] host= port=9999
56+
[Original ] 127.0.0.1:9999
57+
[SplitHostPort] host=127.0.0.1 port=9999
58+
[Original ] localhost:9999
59+
[SplitHostPort] host=localhost port=9999
60+
[Original ] [::1]:9999
61+
[SplitHostPort] host=::1 port=9999
62+
[Original ] [fe80::a%eth0]:9999
63+
[SplitHostPort] host=fe80::a%eth0 port=9999
64+
65+
66+
[Elapsed] 100.64µs
67+
*/
68+
4569
}

0 commit comments

Comments
 (0)