美文网首页
Let's Go Two

Let's Go Two

作者: zgq_70ae | 来源:发表于2018-11-16 23:55 被阅读0次

    Two

    os.Setenv(key, string) 设置主机的环境变量,key是环境变量,string是设置的值

    例子 :str := os.Setenv(key,value) 如果出错,返回一个错误类型
    fmt.Printf("%s", str)
    运行程序:
    go run main.go
    打印结果:

    fmt.Clearenv()无参数,无返回值,慎用! 清除所有环境变量

    例子 : os.Clearenv()

    运行程序:
    go run main.go
    打印结果:

    os.Exit(code int)按照给定的退出码退出程序,0表示成功,非0表示出错,执行这个不会执行defer函数,以后讲。

    例子 : os.Exit(0)

    运行程序:
    go run main.go
    打印结果:

    os.Getuid() 返回调用者的用户id

    例子 : os.Getuid() 返回一个int

    运行程序:
    go run main.go
    打印结果:
    1000

    os.Geteuid()返回调用者的有效用户id

    例子 : os.Geteuid() 返回一个int

    运行程序:
    go run main.go
    打印结果:
    1000

    good bye~

    相关文章

      网友评论

          本文标题:Let's Go Two

          本文链接:https://www.haomeiwen.com/subject/geovfqtx.html