需要一个额外的包:runtime

runtime.GOARCH 返回当前的系统架构;runtime.GOOS 返回当前的操作系统。
示例:

package main

import (
	"fmt"
	"runtime"
)

func main() {
    //runtime.GOARCH 返回当前的系统架构;runtime.GOOS 返回当前的操作系统。
	sysType := runtime.GOOS

	if sysType == "linux" {
		// LINUX系统
		fmt.Println("Linux system")
	}

	if sysType == "windows" {
		// windows系统
		fmt.Println("Windows system")
	}
}