Go语言写的解析器(支持linq,sql,json,fmt,net, http)

2023-12-15 156 views
2
项目推荐
  • 项目名称: monkey

  • 项目地址: https://github.com/haifenghuang/monkey

  • 项目语言: go

  • 项目描述: 一个使用go语言编写的解析器,支持linq,sql,json,fmt,net, http等。

  • 推荐理由: 为了自己好好自学go语言,同时为了更好的理解编程语言

  • 示例代码:

    
    //define a function
    let add = fn() { [5,6] }
    let n = [1, 2] + [3, 4] + add()
    println(n)

//fmt module let i = 108, f = 25.383, b=true, s = "Hello, world", aArr = [1, 2, 3, 4, "a", "b"], aHash = { "key1" => 1, "key2" => 2, "key3" => "abc"}

// Use '%v (value)' to print variable value, '%_' to print the variable's type fmt.printf("i=[%05d, %X], b=[%t], f=[%.5f], s=[%-15s], aArr=%v, aHash=%v\n", i, i, b, f, s, aArr, aHash)

//linq module let mm = [1,2,3,4,5,6,7,8,9,10] println('before mm={mm}')

result = linq.from(mm).where(fn(x) { x % 2 == 0 }).select(fn(x) { x = x + 2 }).toSlice() println('after result={result}')

result = linq.from(mm).where(fn(x) { x % 2 == 0 }).select(fn(x) { x = x + 2 }).last() println('after result={result}')

let sortArr = [1,2,3,4,5,6,7,8,9,10] result = linq.from(sortArr).sort(fn(x,y){ return x > y }) println('[1,2,3,4,5,6,7,8,9,10] sort(x>y)={result}')

result = linq.from(sortArr).sort(fn(x,y){ return x < y }) println('[1,2,3,4,5,6,7,8,9,10] sort(x<y)={result}')


- 截图:
![default](https://user-images.githubusercontent.com/4425219/32663200-0c60bb4c-c668-11e7-87ac-a44d420be54f.png)

![default](https://user-images.githubusercontent.com/4425219/32663234-32cca548-c668-11e7-9827-bee5fd4fcd93.png)

回答