判定操作系统

package main
 
import (
    "fmt"
    "runtime"
)
 
func main() {
    fmt.Println("You are running on:")
    switch runtime.GOOS {
    case "windows":
        fmt.Println("Windows")
    case "linux":
        fmt.Println("Linux")
    case "darwin":
        fmt.Println("macOS")
    default:
        fmt.Println("Unknown OS")
    }
}

  

posted @ 2024-12-20 14:59  飞雪飘鸿  阅读(4)  评论(0编辑  收藏  举报
https://damo.alibaba.com/ https://tianchi.aliyun.com/course?spm=5176.21206777.J_3941670930.5.87dc17c9BZNvLL