Skip to content

🖥️ GetPlatformName ​

Returns the current operating system platform name.

When to Use ​

Use this when you need to branch install logic by operating system or record the runtime environment. Based on runtime.GOOS. 🔍

Signature ​

go
func GetPlatformName() string

Parameters ​

ParameterTypeDescription
None—Package-level function, takes no parameters

Return Value ​

  • string: Operating system identifier, e.g. linux, darwin, windows. ✅

Example ​

go
package main

import (
	"fmt"

	"github.com/scagogogo/composer-skills/pkg/installer"
)

func main() {
	fmt.Printf("current platform: %s\n", installer.GetPlatformName())
}

Advanced ​

  • Commonly used to gate platform-specific methods before calling them, e.g. only considering Homebrew on macOS. 🛠️
  • For the companion architecture info, use GetArchName. 🧩
  • This value comes directly from runtime.GOOS, consistent with the output of uname. 🐧

Released under the MIT License