platform

package
v1.0.31-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package platform shows elements only on some platforms:

giode.OnlyOn(giode.PlatformWindows, func() giode.Element { return windowsTitleBar() })

The platform is fixed when the app is built (Current is a constant), so OnlyOn costs one comparison, and the builders for other platforms are never called.

Index

Constants

View Source
const Current = current

Current is the platform the app was built for.

Variables

This section is empty.

Functions

func ByPlatform

func ByPlatform(v Views) base.Element

ByPlatform returns the element the current platform's builder in v makes (see Views).

func Is

func Is(p Platform) bool

Is reports whether the app runs on one of p's platforms.

func OnlyOn

func OnlyOn(p Platform, build func() base.Element) base.Element

OnlyOn returns the element build makes on p's platforms, and an empty element (no size, nothing drawn) elsewhere, where build isn't called.

Types

type Platform

type Platform uint8

Platform is a set of platforms. Combine them with |: Windows|Linux.

const (
	Windows Platform = 1 << iota
	// MacOS is macOS, not iOS.
	MacOS
	// Linux is Linux desktops (and other Unix desktops: FreeBSD,
	// OpenBSD), not Android.
	Linux
	Android
	IOS
	// Web is the browser (WebAssembly).
	Web

	// Desktop is Windows, macOS and Linux; Mobile is Android and iOS.
	Desktop = Windows | MacOS | Linux
	Mobile  = Android | IOS
	// Any is every platform.
	Any = Desktop | Mobile | Web
)

func (Platform) String

func (p Platform) String() string

String names the platform, or the set.

type Views

type Views struct {
	Windows, MacOS, Linux, Android, IOS, Web func() base.Element
	Desktop, Mobile                          func() base.Element
	Default                                  func() base.Element
}

Views is an element for each platform, for ByPlatform. A specific platform's builder wins over Desktop or Mobile, and those over Default; a platform with none of them shows nothing.

Jump to

Keyboard shortcuts

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