使用GOLANG获取系统唯一的UUID

I was trying to figure out a way to get the system unique UUID.

like generated by

sudo dmidecode -s system-uuid

I tried using github.com/satori/go.uuid but each time I execute it, it gives me a new UUID.

The code that I am using is as below.

func main() {

    u2, err := uuid.NewV4()
    if err != nil {
        fmt.Printf("Something went wrong: %s", err)
        return
    }
    fmt.Printf("UUIDv4: %s
", u2)
}

I used "github.com/dselans/dmidecode" for getting the System UUID. dmidecode

Simple Code snippet is below

func main() {
    dmi := dmidecode.New()

    if err := dmi.Run(); err != nil {
        fmt.Printf("Unable to get dmidecode information. Error: %v
", err)
    }

    byNameData, _ := dmi.SearchByName("UUID")
    fmt.Printf("uuid2: %v ", byNameData)

}