Skip to content

Instantly share code, notes, and snippets.

@fjudith
Created April 19, 2017 21:44
Show Gist options
  • Save fjudith/8fc40b16ba52581eba7073f2f253cf4e to your computer and use it in GitHub Desktop.
Save fjudith/8fc40b16ba52581eba7073f2f253cf4e to your computer and use it in GitHub Desktop.
uuidgen.exe using Go/Golang

Source

Create a file named uuidgen.go.

package main

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

func main() {
    out, err := exec.Command("uuidgen").Output()
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%s", out)
}

Test

Run the following command test uuid generator

go run uuidgen.go

Build

Run the following command to build uuidgen.exe.

GOOS=windows GOARCH=amd64 go build -o uudigen.exe uuidgen.go 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment