Libcorn native Go implementation
Find a file
2024-05-10 17:48:42 +01:00
.idea chore: initial commit 2024-05-02 22:29:09 +01:00
.gitignore feat: implement v0.10 spec 2024-05-10 17:47:25 +01:00
corn.go feat: implement v0.10 spec 2024-05-10 17:47:25 +01:00
evaluator.go feat: implement v0.10 spec 2024-05-10 17:47:25 +01:00
evaluator_test.go feat: implement v0.10 spec 2024-05-10 17:47:25 +01:00
go.mod feat: implement v0.10 spec 2024-05-10 17:47:25 +01:00
go.sum feat: implement v0.10 spec 2024-05-10 17:47:25 +01:00
parser.go feat: implement v0.10 spec 2024-05-10 17:47:25 +01:00
README.md docs(readme): fix libcorn link 2024-05-10 17:48:42 +01:00
tokenizer.go feat: implement v0.10 spec 2024-05-10 17:47:25 +01:00

Corn Go

Go implementation of libcorn.

This is a full-spec implementation, which passes the reference test suite, so should work as expected. That said, it has not currently been road-tested, and the code is rough around the edges, so I would not regard it production-ready.

Usage

Add the dependency:

go get github.com/corn-config/corn-go
package main

import (
  "fmt"
  "github.com/corn-config/corn-go"
)

func main() {
  input := "let { $foo = 42} in { num = $foo }"
  eval, err := corn.Evaluate(input)

  if err != nil {
    // handle
  }

  fmt.Println(eval.Value.Get("num")) // -> 42
}

Support for deserializing into structs is currently missing. Only Evaluate method is exposed currently, which will return an unstructured map.