githuboutput

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 4 Imported by: 1

README

github-output

Godoc license

go get github.com/ci-space/github-output@v0.1.0

github-output - is simple GO library for writing values into $GITHUB_OUTPUT

Usage

Write single value
package main

import githuboutput "github.com/ci-space/github-output"

func main() {
	githuboutput.Write("name", "Ivan")
}
Write many values
package main

import githuboutput "github.com/ci-space/github-output"

func main() {
	githuboutput.WriteMap(map[string]string{
		"name": "Ivan",
		"last_name": "Ivanov",
    })
}
Write when output is available
package main

import githuboutput "github.com/ci-space/github-output"

func main() {
	githuboutput.WhenAvailable(func() error {
        return githuboutput.Write("key", "value")
	})
}

Documentation

Index

Constants

View Source
const EnvName = "GITHUB_OUTPUT"

Variables

View Source
var ErrEnvVarNotFound = errors.New("environment variable not found")

Functions

func WhenAvailable added in v0.1.1

func WhenAvailable(write func() error) error

func Write

func Write(key string, value string) error

func WriteMap

func WriteMap(values map[string]string) error

Types

type Env

type Env interface {
	// Get can return ErrEnvVarNotFound
	Get(key string) (string, error)
}

type LocalEnv

type LocalEnv struct{}

func NewLocalEnv

func NewLocalEnv() *LocalEnv

func (LocalEnv) Get

func (LocalEnv) Get(key string) (string, error)

type MapEnv

type MapEnv map[string]string

func (*MapEnv) Get

func (e *MapEnv) Get(key string) (string, error)

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(env Env) *Writer

func (*Writer) WriteMap

func (w *Writer) WriteMap(values map[string]string) error

Jump to

Keyboard shortcuts

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