platform

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package platform is a utility for handling platform data

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Platform

type Platform struct {
	Os   string `yaml:"os"`
	Arch string `yaml:"arch"`
}

Platform holds an os/architecture pair.

func CurrentPlatform

func CurrentPlatform() Platform

CurrentPlatform returns the platform defined by GOOS and GOARCH.

func Parse added in v0.12.0

func Parse(s string) Platform

func (Platform) Empty added in v0.12.0

func (p Platform) Empty() bool

func (Platform) Equals

func (p Platform) Equals(other Platform) bool

Equals is an equality test between this platform and the other.

Example
package main

import (
	"fmt"

	"github.com/cloudfoundry/cloud-service-broker/internal/brokerpak/platform"
)

func main() {
	p := platform.Platform{Os: "beos", Arch: "webasm"}
	fmt.Println(p.Equals(p))
	fmt.Println(p.Equals(platform.CurrentPlatform()))

}
Output:

true
false

func (Platform) MatchesCurrent

func (p Platform) MatchesCurrent() bool

MatchesCurrent returns true if the platform matches this binary's GOOS/GOARCH combination.

Example
package main

import (
	"fmt"

	"github.com/cloudfoundry/cloud-service-broker/internal/brokerpak/platform"
)

func main() {
	fmt.Println(platform.CurrentPlatform().MatchesCurrent())

}
Output:

true

func (Platform) String

func (p Platform) String() string

String formats the platform as an os/arch pair.

Example
package main

import (
	"fmt"

	"github.com/cloudfoundry/cloud-service-broker/internal/brokerpak/platform"
)

func main() {
	p := platform.Platform{Os: "bsd", Arch: "amd64"}
	fmt.Println(p.String())

}
Output:

bsd/amd64

func (Platform) Validate

func (p Platform) Validate() (errs *validation.FieldError)

Validate implements validation.Validatable.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL