Skip to content

Commit 6212930

Browse files
authored
Merge pull request #766 from devlights/add-os-clearenv-example
2 parents 8d3da4f + 4fcf631 commit 6212930

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

examples/basic/osop/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
| expand.go | osop_expand | os.Expand() のサンプルです。 |
1414
| setenv.go | osop_setenv | os.Setenv() のサンプルです。 |
1515
| unsetenv.go | osop_unsetenv | os.Unsetenv() のサンプルです。 |
16+
| clearenv.go | osop_clearenv | os.Clearenv() のサンプルです。 |

examples/basic/osop/clearenv.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package osop
2+
3+
import (
4+
"os"
5+
6+
"github.com/devlights/gomy/output"
7+
)
8+
9+
// Clearenv は、os.Clearenv() のサンプルです。
10+
//
11+
// 全環境変数をクリアします。(このプロセス上での)
12+
//
13+
// # REFERENCES
14+
//
15+
// - https://pkg.go.dev/os@go1.22.0#Clearenv
16+
func Clearenv() error {
17+
var envs []string
18+
19+
envs = os.Environ()
20+
output.Stdoutl("[os.Environ]", len(envs))
21+
22+
os.Clearenv()
23+
24+
envs = os.Environ()
25+
output.Stdoutl("[os.Environ]", len(envs))
26+
27+
return nil
28+
}

examples/basic/osop/examples.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ func (r *register) Regist(m mapping.ExampleMapping) {
2222
m["osop_expand"] = Expand
2323
m["osop_setenv"] = Setenv
2424
m["osop_unsetenv"] = Unsetenv
25+
m["osop_clearenv"] = Clearenv
2526
}

0 commit comments

Comments
 (0)