Skip to content

Commit f495607

Browse files
authored
Merge pull request #737 from devlights/add-result-in-example
2 parents 3bceef9 + 3b4ab0f commit f495607

File tree

6 files changed

+107
-7
lines changed

6 files changed

+107
-7
lines changed

examples/basic/osop/README.md

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

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

5-
| file | example name | note |
6-
|----------------|-----------------------|---------------------------|
7-
| mkdir.go | osop\_mkdir | os.Mkdir/MkdirAllのサンプルです. |
8-
| listprocess.go | osop\_list\_processes | プロセスリストを取得するサンプルです. |
5+
| file | example name | note |
6+
| -------------- | ------------------- | ------------------------------------- |
7+
| mkdir.go | osop_mkdir | os.Mkdir/MkdirAllのサンプルです. |
8+
| listprocess.go | osop_list_processes | プロセスリストを取得するサンプルです. |

examples/basic/osop/listprocess.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,32 @@ func ListProcesses() error {
5151
}
5252

5353
return nil
54+
55+
/*
56+
$ task
57+
task: [build] go build .
58+
task: [run] ./try-golang -onetime
59+
60+
ENTER EXAMPLE NAME: osop_list_processes
61+
62+
[Name] "osop_list_processes"
63+
[info] name=/ide/node pid=1132
64+
[info] name=/ide/node pid=1534
65+
[info] name=/ide/node pid=1559
66+
[info] name=/ide/node pid=1968
67+
[info] name=/home/gitpod/go-packages/bin/gopls pid=5948
68+
[info] name=/ide/node pid=658
69+
[info] name=/home/gitpod/go-packages/bin/staticcheck pid=6660
70+
[info] name=/usr/bin/dash pid=68
71+
[info] name=/ide/node pid=77
72+
[info] name=/workspace/go/bin/task pid=8715
73+
[info] name=/usr/bin/bash pid=89
74+
[info] name=/workspace/try-golang/try-golang pid=8903
75+
[info] name=/workspace/try-golang/try-golang pid=self
76+
[info] name=/workspace/try-golang/try-golang pid=thread-self
77+
78+
79+
[Elapsed] 1.94092ms
80+
*/
81+
5482
}

examples/basic/osop/mkdir.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,22 @@ func Mkdir() error {
5656
output.Stdoutf("[ls -l]", "%s\n", b)
5757

5858
return nil
59+
60+
/*
61+
$ task
62+
task: Task "build" is up to date
63+
task: [run] ./try-golang -onetime
64+
65+
ENTER EXAMPLE NAME: osop_mkdir
66+
67+
[Name] "osop_mkdir"
68+
[ls -l] total 0
69+
drwxr-xr-x 2 gitpod gitpod 40 Jan 29 04:18 d1
70+
drwxr-xr-x 2 gitpod gitpod 40 Jan 29 04:18 d2
71+
72+
73+
74+
[Elapsed] 2.049119ms
75+
*/
76+
5977
}

examples/basic/panics/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

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

5-
| file | example name | note |
6-
|------------------------|-----------------------------|----------------------|
7-
| panic\_and\_recover.go | panics\_panic\_and\_recover | panicとrecoverのサンプルです |
5+
| file | example name | note |
6+
| ------------------------- | ------------------------ | ------------------------------------------------------------------- |
7+
| panic_and_recover.go | panics_panic_and_recover | panicとrecoverのサンプルです |
8+
| panics_panic_and_defer.go | panics_panic_and_defer | panicが呼ばれた場合でもdeferは処理されることを確認するサンプルです. |

examples/basic/panics/panic_and_defer.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,41 @@ func PanicAndDefer() error {
2020
proc()
2121

2222
return nil
23+
24+
/*
25+
$ task
26+
task: [build] go build .
27+
task: [run] ./try-golang -onetime
28+
29+
ENTER EXAMPLE NAME: panics_panic_and_defer
30+
31+
[Name] "panics_panic_and_defer"
32+
[raise] call defer
33+
[caller] call defer
34+
[root] call defer
35+
36+
37+
[Elapsed] 50.4µs
38+
END
39+
panic: test
40+
41+
goroutine 1 [running]:
42+
github.com/devlights/try-golang/examples/basic/panics.PanicAndDefer.func1()
43+
/workspace/try-golang/examples/basic/panics/panic_and_defer.go:12 +0x68
44+
github.com/devlights/try-golang/examples/basic/panics.PanicAndDefer.func2()
45+
/workspace/try-golang/examples/basic/panics/panic_and_defer.go:16 +0x65
46+
github.com/devlights/try-golang/examples/basic/panics.PanicAndDefer()
47+
/workspace/try-golang/examples/basic/panics/panic_and_defer.go:20 +0x90
48+
github.com/devlights/try-golang/runner.(*Exec).Run(0x6070100?)
49+
/workspace/try-golang/runner/exec.go:52 +0x135
50+
github.com/devlights/try-golang/runner.(*Loop).exec(0xc00002e2d0?, {0x9a7126, 0x16}, 0xc0000af950)
51+
/workspace/try-golang/runner/loop.go:126 +0x85
52+
github.com/devlights/try-golang/runner.(*Loop).Run(0xc000074408)
53+
/workspace/try-golang/runner/loop.go:79 +0x23d
54+
github.com/devlights/try-golang/cmd.Execute()
55+
/workspace/try-golang/cmd/root.go:66 +0x627
56+
main.main()
57+
/workspace/try-golang/main.go:6 +0xf
58+
*/
59+
2360
}

examples/basic/panics/panic_and_recover.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ func PanicAndRecover() error {
1414
}
1515

1616
return nil
17+
18+
/*
19+
$ task
20+
task: [build] go build .
21+
task: [run] ./try-golang -onetime
22+
23+
ENTER EXAMPLE NAME: panics_panic_and_recover
24+
25+
[Name] "panics_panic_and_recover"
26+
[panic] panic時deferは呼ばれる
27+
[catch] error occurred in raise()
28+
29+
30+
[Elapsed] 51.68µs
31+
*/
32+
1733
}
1834

1935
func catch() (err error) {

0 commit comments

Comments
 (0)