golang - 获取当前用户的Home目录

go-bot

2018-04-26T08:12:02Z||2018-04-26T08:12:02Z

package main

import (
    "fmt"
    "log"
    "os/user"
)

func main() {
    usr, err := user.Current()
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(usr.HomeDir)
}