lambda

module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: GPL-3.0

README

λ

lambda-tests lambda-logo

λ is a functional programming framework for go, which adds support for an alternative error handling workflow using options.

Example usage

Read all lines from stdin
package main

import (
	"fmt"
	λ "github.com/4thel00z/lambda/v1"
	"os"
)

func main() {
	content := λ.Slurp(os.Stdin).UnwrapString()
	// do things with content...
}


Read a file and pipe it to stdout
package main

import (
	λ "github.com/4thel00z/lambda/v1"
	"os"
)

func main() {
	λ.Open("lorem_ipsum.txt").Slurp().WriteString(os.Stdout)
}
Read a JSON file into a struct
package main

import (
	λ "github.com/4thel00z/lambda/v1"
	"strings"
)

type MagicSpell struct {
	Name        string  `json:"name"`
	AttackPower float64 `json:"attack_power"`
	Type        string  `json:"type"`
	Description string  `json:"description"`
}

func main() {
	var (
		m MagicSpell
	)
	λ.Open("magic.json").Slurp().JSON(&m).Catch(λ.Die)
}

Todo

  • Make Option more flexible an pretty
  • Add methods for handling conditionals

License

This project is licensed under the GPL-3 license.

Directories

Path Synopsis
example
echo_stdin command
io command
json command

Jump to

Keyboard shortcuts

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