Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

tengo

> 编程语言
Open source

A fast script language for Go

3.8K stars0 likes0 views
WebsiteGitHub

About

A fast script language for Go

The Tengo Language

Tengo is a small, dynamic, fast, secure script language for Go.

Tengo is fast and secure because it's compiled/executed as bytecode on stack-based VM that's written in native Go.

/* The Tengo Language */
fmt := import("fmt")

each := func(seq, fn) {
    for x in seq { fn(x) }
}

sum := func(init, seq) {
    each(seq, func(x) { init += x })
    return init
}

fmt.println(sum(0, [1, 2, 3]))   // "6"
fmt.println(sum("", [1, 2, 3]))  // "123"

Test this Tengo code in the Tengo Playground

Features

  • Simple and highly readable Syntax
    • Dynamic typing with type coercion
    • Higher-order functions and closures
    • Immutable values
  • Securely Embeddable and Extensible
  • Compiler/runtime written in native Go (no external deps or cgo)
  • Executable as a standalone language / REPL
  • Use cases: rules engine, state machine, data pipeline, transpiler

Benchmark

fib(35) fibt(35) Language (Type) Tengo 2,315ms 3ms Tengo (VM) go-lua 4,028ms 3ms Lua (VM) GopherLua 4,409ms 3ms Lua (VM) goja 5,194ms 4ms JavaScript (VM) starlark-go 6,954ms 3ms Starlark (Interpreter) gpython 11,324ms 4ms Python (Interpreter) Yaegi 11,715ms 10ms Yaegi (Interpreter) otto 48,539ms 6ms JavaScript (Interpreter) Anko 52,821ms 6ms Anko (Interpreter) - - - - Go 47ms 2ms Go (Native) Lua 756ms 2ms Lua (Native) Python 1,907ms 14ms Python2 (Native)

* fib(35): Fibonacci(35)
* fibt(35): tail-call version of Fibonacci(35)
* Go does not read the source code from file, while all other cases do
* See here for commands/codes used

Quick Start

go get github.com/d5/tengo/v2

A simple Go example code that compiles/runs Tengo script code with some input/output values:

…

Or, if you need to evaluate a simple expression, you can use Eval function instead:

res, err := tengo.Eval(ctx,
	`input ? "success" : "fail"`,
	map[string]interface{}{"input": 1})
if err != nil {
	panic(err)
}
fmt.Println(res) // "success"

References

  • Language Syntax
  • Object Types
  • Runtime Types and Operators
  • Builtin Functions
  • Interoperability
  • Tengo CLI
  • Standard Library
  • Syntax Highlighters: VSCode, Atom, Vim, Emacs
  • Why the name Tengo? It's from 1Q84.

GitHub Issues· 90 open

View all on GitHub
  • #469

    times.in_location Runtime Error in Some Computer

    Updated Apr 22, 2026
  • #472

    json.Number can't pass in vm

    Updated Nov 29, 2025
  • #471

    [Question] What is the recommended pattern for injecting Go variables to override in-script defaults?

    Updated Oct 29, 2025
  • #468

    Example to make function call and retrieve result.

    Updated Jul 28, 2025
  • #467

    A case where closure doesn't have access to imported modules

    Updated Jul 17, 2025
  • #466

    Import path for v3

    Updated Jun 8, 2025
  • #453

    Tengo with LLM

    Updated Apr 8, 2025
  • #441

    [question] How can I register native type into script?

    Updated Feb 17, 2025

Highlights

  • •Simple and highly readable
  • •Dynamic typing with type coercion
  • •Higher-order functions and closures
  • •Immutable values
  • •Securely Embeddable
  • •Compiler/runtime written in native Go _(no external deps or cgo)_
  • •Executable as a
  • •Use cases: rules engine, state machine,
  • •Language Syntax
  • •Object Types

> Tags

Gocompilerembedded-languagegogolang

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言