Description
Expression language(EL) to manipulate Golang structure data. Its main purpose is to find reflect.Value by Expression, then do some reading and writing.
go-el alternatives and similar packages
Based on the "Utilities" category.
Alternatively, view go-el alternatives based on common mentions on social networks and blogs.
-
项目文档
🚀Vite+Vue3+Gin拥有AI辅助的基础开发平台,支持TS和JS混用。它集成了JWT鉴权、权限管理、动态路由、显隐可控组件、分页封装、多点登录拦截、资源权限、上传下载、代码生成器、表单生成器和可配置的导入导出等开发必备功能。 -
excelize
Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets -
Kopia
Cross-platform backup tool for Windows, macOS & Linux with fast, incremental backups, client-side end-to-end encryption, compression and data deduplication. CLI and GUI included. -
goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report. -
create-go-app
✨ A complete and self-contained solution for developers of any qualification to create a production-ready project with backend (Go), frontend (JavaScript, TypeScript) and deploy automation (Ansible, Docker) by running only one CLI command. -
EaseProbe
A simple, standalone, and lightweight tool that can do health/status checking, written in Go. -
filetype
Fast, dependency-free Go package to infer binary file types based on the magic numbers header signature -
boilr
:zap: boilerplate template manager that generates files or directories from template repositories -
beaver
💨 A real time messaging system to build a scalable in-app notifications, multiplayer games, chat apps in web and mobile apps. -
go-underscore
Helpfully Functional Go - A useful collection of Go utilities. Designed for programmer happiness.
CodeRabbit: AI Code Reviews for Developers

Do you think we are missing an alternative of go-el or a related project?
Popular Comparisons
README
go-el
Expression language(EL) to manipulate Golang structure data. Its main purpose is to find reflect.Value
by Expression, then do some reading and writing.
Installation
Simple as it takes to type the following command:
go get github.com/lysu/go-el
and import with
import github.com/lysu/go-el
Usage
Example Data
As example, we have some data like this:
type Comment struct {
NickName string
Content string
Date time.Time
}
type Author struct {
Name string
}
type Blog struct {
Title string
RoleState map[string]uint
CommentIds []uint64
Comments map[string]*Comment
}
func (b Blog) FirstComment() *Comment {
return b.Comments["0"]
}
then we init them with some test data:
b := &Blog{
Title: "Blog title1",
CommentIds: []uint64{1, 3},
Comments: map[string]*Comment{
"0": {
NickName: "000",
Content: "test",
Date: time.Now(),
},
"1": {
NickName: "u1",
Content: "test",
Date: time.Now(),
},
"3": {
NickName: "tester",
Content: "test hehe...",
Date: time.Now(),
},
},
Author: Author{
Name: "Author 1",
},
RoleState: map[string]uint{},
}
Expression
Using el.Expression
, we can navigate from root(b
) to anywhere in this structure.
1. To field
exp := el.Expression("Title")
v, _ := exp.Execute(&data)
fmt.Printf("%v\n", v.interface()) //==> Blog title1
2. To nested field
exp := el.Expression("Author.Name")
v, _ := exp.Execute(&data)
fmt.Printf("%v\n", v.interface()) //==> Author 1
3. To slice/array/string item
exp := el.Expression("CommentIds[0]")
v, _ := exp.Execute(&data)
fmt.Printf("%v\n", v.interface()) //==> 1
4. To map item
exp := el.Expression("Comments["3"].NickName")
v, _ := exp.Execute(&data)
fmt.Printf("%v\n", v.interface()) //==> tester
5. Item in[]
also can be another Expression
exp := el.Expression("Comments["CommentIds[0]].NickName")
v, _ := exp.Execute(&data)
fmt.Printf("%v\n", v.interface()) //==> u1
6. Call function
function can return only ONE
result
exp := el.Expression("FirstComment().Content")
v, _ := exp.Execute(&data)
fmt.Printf("%v\n", v.interface()) //==> test
7. Modify Value
After Execute
expression, we got a relfect.Value
, we also can use it to modify data, e.g.
exp := el.Expression("FirstComment().Content")
v, _ := exp.Execute(&data)
v.SetString("1111")
will let first comment with value 1111
Beside that we recommend users take a moment to look The Laws of Reflection, take care some limition that reflect has.
Patcher
Base on Expression, we also provide a tool named Patcher
, the purpose of it is to let use modify object with expression easier and be batched.
We found it's very useful to build HTTP Patch API to partial update entity
ps := p.Patch{
"Author.Name": "ほん",
"Comments[CommentIds[0]].NickName": "私",
"roleState[100]": uint(100),
}
err := patcher.PatchIt(b, ps)
This will modify three properties at once~ (but we still meet some rule of refect, like map-value use ptr.. and so on)
More
See our Example in Unit-Test:
TODO
generate expression between two data..like diff..- -?
Thanks
- Many code was extract from flosch/pongo2 --- An cool template-engine
- The presentation by Rob Pike titled Lexical Scanning in Go