marker

package module
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: MIT Imports: 14 Imported by: 0

README

✏️ Marker

Mark your golang plugin file to get the best of it

Marker Travis Status Marker Code Coverage Marker License Marker Last Release


Usage | Installation | License


I know that this (✏️) is not a marker, but I do not have anything better \( ̄▽ ̄)/

Usage

Actually I'd suggest you to go into the examples directory to see more usage variations.

Project:

project
├── config.go
└── app/
    └── main.go

config.go

package main // Notice that the package has to be main to build a plugin.

// Variables and functions also have to be public to import them using marker. 
var ApiUrl = "https://api.github.com"

app/main.go

package main
 
import (
    "fmt"
    "github.com/olehan/marker"
    "github.com/olehan/marker/path"
)

func main() {
    // Here we're marking our file as a plugin and telling the marker what we need
    // and what it should be.
    output, err := marker.Mark(
        path.RelativeToCaller("../config.go"),
        // We're specifying the variable's name and its type so marker could
        // validate the value that was imported from the plugin.
        marker.NewMarker("ApiUrl", marker.StringValue),
    )

    if err != nil {
        panic(err)
    }

    // Symbol's always pointer.
    apiUrl := output.(*string)   
    fmt.Println("apiUrl:", *apiUrl)
}

Installation

$ go get github.com/olehan/marker

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BoolValue       = reflect.ValueOf(false)
	IntValue        = reflect.ValueOf(0)
	Int8Value       = reflect.ValueOf(int8(0))
	Int16Value      = reflect.ValueOf(int16(0))
	Int32Value      = reflect.ValueOf(int32(0))
	Int64Value      = reflect.ValueOf(int64(0))
	UintValue       = reflect.ValueOf(uint(0))
	Uint8Value      = reflect.ValueOf(uint8(0))
	Uint16Value     = reflect.ValueOf(uint16(0))
	Uint32Value     = reflect.ValueOf(uint32(0))
	Uint64Value     = reflect.ValueOf(uint64(0))
	UintptrValue    = reflect.ValueOf(uintptr(0))
	Float32Value    = reflect.ValueOf(float32(0.0))
	Float64Value    = reflect.ValueOf(0.0)
	StringValue     = reflect.ValueOf("")
	Complex64Value  = reflect.ValueOf(complex64(0.0))
	Complex128Value = reflect.ValueOf(complex128(0.0))
)

Functions

func Mark

func Mark(filePath string, marker *Marker) (output.Output, error)

func MarkMany

func MarkMany(filePath string, markers ...*Marker) (output.Outputs, error)

Types

type Marker

type Marker struct {
	Name  string
	Value reflect.Value
}

func NewMarker

func NewMarker(name string, value interface{}) *Marker

func NewValueMarker

func NewValueMarker(name string, value reflect.Value) *Marker

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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