Moving to mojosa-software.

This commit is contained in:
Andrey Parhomenko 2023-06-26 12:16:52 +03:00
parent 029d66a8b8
commit 9fb929825a
56 changed files with 136 additions and 154 deletions

View file

@ -1,3 +1,5 @@
var strings = import("strings")
e = 5
v = 53
println(e + v)
@ -6,6 +8,10 @@ for v in Cmd("ls").Stdout().ShSplit() {
println("file:", v)
}
for v in strings.Split("big dick and me", " ") {
println(v)
}
if v < 55 {
println("it fucking works")
}

7
go.mod
View file

@ -1,9 +1,8 @@
module github.com/surdeus/goblin
module github.com/mojosa-software/goblin
go 1.18
require (
github.com/surdeus/anko v0.0.0-20230614164331-b18c1239c632 // indirect
github.com/surdeus/gomtool v0.0.0-20230324173629-09da5dcd0204 // indirect
github.com/surdeus/goscript v0.0.0-20230620135552-456d895c0747 // indirect
github.com/mojosa-software/gomtool v0.0.0-20230626085847-176486ff01a2
github.com/mojosa-software/goscript v0.0.0-20230626091305-86a004b7769c
)

30
go.sum
View file

@ -1,26 +1,4 @@
github.com/k1574/gomtool v0.0.0-20220616060224-023d1559d777 h1:r4Wm40GwE7GNC3VbIwVGtD8dPDw5NDsI5xlpcYF5Nv4=
github.com/k1574/gomtool v0.0.0-20220616060224-023d1559d777/go.mod h1:XT2+xWYiSEE6eX/nBgE6UnfIrBfijwPfv4fNJSVD+SA=
github.com/surdeus/anko v0.0.0-20230614164331-b18c1239c632 h1:sbiNV1CbS7LwhLppLn6STcs0PBVHGhjPMPbE/nA1DmE=
github.com/surdeus/anko v0.0.0-20230614164331-b18c1239c632/go.mod h1:4lXky1Kj62zRKAa5nUIwxC19eUZeV4XkEr6MLWd8GMM=
github.com/surdeus/gomtool v0.0.0-20220806023210-bb1d6be89aa1 h1:eTeqQV207H2ho0QFMxgxI75oT8E69aExmX6f6oltl9Y=
github.com/surdeus/gomtool v0.0.0-20220806023210-bb1d6be89aa1/go.mod h1:48d4QXOu0MwH0fbqseBInNdS6WiJ0+EzZU9K5sGu4uo=
github.com/surdeus/gomtool v0.0.0-20221011123848-b7dbc364ea3a h1:fUBhJuFtPNsJCi5//PT+Ni/QMNWzDVig28WK99FTkp0=
github.com/surdeus/gomtool v0.0.0-20221011123848-b7dbc364ea3a/go.mod h1:48d4QXOu0MwH0fbqseBInNdS6WiJ0+EzZU9K5sGu4uo=
github.com/surdeus/gomtool v0.0.0-20221123071619-d67de6873631 h1:dSnG4J2jusYRVnRRmuiqzSkl4vRMIJOQyI04UfKIwIM=
github.com/surdeus/gomtool v0.0.0-20221123071619-d67de6873631/go.mod h1:48d4QXOu0MwH0fbqseBInNdS6WiJ0+EzZU9K5sGu4uo=
github.com/surdeus/gomtool v0.0.0-20230216120523-b00a31dd9887 h1:lKe6TayY2qB50RqPYrHBlHPeJPevNViM+UQn8/2jBxc=
github.com/surdeus/gomtool v0.0.0-20230216120523-b00a31dd9887/go.mod h1:48d4QXOu0MwH0fbqseBInNdS6WiJ0+EzZU9K5sGu4uo=
github.com/surdeus/gomtool v0.0.0-20230324065513-d8d05cb8077d h1:COfpUMABa+RrsD05bOnXDx9FX+oaJ+dnKiLpqOODxl8=
github.com/surdeus/gomtool v0.0.0-20230324065513-d8d05cb8077d/go.mod h1:48d4QXOu0MwH0fbqseBInNdS6WiJ0+EzZU9K5sGu4uo=
github.com/surdeus/gomtool v0.0.0-20230324070550-2fb327b6a6a6 h1:aOXHUmhQS/mCo8r72dERsxAnYrlk/hP61BAyZ79MkDs=
github.com/surdeus/gomtool v0.0.0-20230324070550-2fb327b6a6a6/go.mod h1:48d4QXOu0MwH0fbqseBInNdS6WiJ0+EzZU9K5sGu4uo=
github.com/surdeus/gomtool v0.0.0-20230324073313-c382bc403f8b h1:9IJVeXxRDTPlp12DQ8M76ydoyDCUx6J4up5UM2DwIXQ=
github.com/surdeus/gomtool v0.0.0-20230324073313-c382bc403f8b/go.mod h1:48d4QXOu0MwH0fbqseBInNdS6WiJ0+EzZU9K5sGu4uo=
github.com/surdeus/gomtool v0.0.0-20230324163514-3199e25c3890 h1:mT4VDgCb2AgPfq2k4GfXI8O3I2sIjHJUaJwBvx95AYM=
github.com/surdeus/gomtool v0.0.0-20230324163514-3199e25c3890/go.mod h1:48d4QXOu0MwH0fbqseBInNdS6WiJ0+EzZU9K5sGu4uo=
github.com/surdeus/gomtool v0.0.0-20230324171804-d106f3a7c3da h1:Wm3ZbhHuH/26B4/vde1S/7t3UPdAXVH7aX1LmHtUTWw=
github.com/surdeus/gomtool v0.0.0-20230324171804-d106f3a7c3da/go.mod h1:48d4QXOu0MwH0fbqseBInNdS6WiJ0+EzZU9K5sGu4uo=
github.com/surdeus/gomtool v0.0.0-20230324173629-09da5dcd0204 h1:eNKjFr0w81mb1d3i2P4uAEIzgc6VVTRJJy6BDWq2vK0=
github.com/surdeus/gomtool v0.0.0-20230324173629-09da5dcd0204/go.mod h1:48d4QXOu0MwH0fbqseBInNdS6WiJ0+EzZU9K5sGu4uo=
github.com/surdeus/goscript v0.0.0-20230620135552-456d895c0747 h1:joKa0jw9NNjL2gfMaUP841AGb74737MiQVh0Nsr7NyQ=
github.com/surdeus/goscript v0.0.0-20230620135552-456d895c0747/go.mod h1:zuG5tMqJ18/QMypvrfgaZw3rR/t4mlWPx4pQmQeq6zU=
github.com/mojosa-software/gomtool v0.0.0-20230626085847-176486ff01a2 h1:xbw1/w6ZB8xRmaTS0mQvfTETF8M2/tSBfHJIR+cJyNE=
github.com/mojosa-software/gomtool v0.0.0-20230626085847-176486ff01a2/go.mod h1:cJ6/4rcQ/s22RTLuLtypFh7gubwG4OLSph3NHX3haAw=
github.com/mojosa-software/goscript v0.0.0-20230626091305-86a004b7769c h1:y7RQZz/zJDARRJkn4szD8N2rK6K9NU1vUNPwahtW5zw=
github.com/mojosa-software/goscript v0.0.0-20230626091305-86a004b7769c/go.mod h1:LtBn7lQTgA/TMEL8Y+dGkD6XWHV2gxRPZXiqCZt3HRc=

60
main.go
View file

@ -1,37 +1,37 @@
package main
import (
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
"github.com/surdeus/goblin/src/tool/awk"
"github.com/surdeus/goblin/src/tool/basename"
"github.com/surdeus/goblin/src/tool/cat"
"github.com/surdeus/goblin/src/tool/date"
"github.com/surdeus/goblin/src/tool/ec"
"github.com/surdeus/goblin/src/tool/echo"
"github.com/surdeus/goblin/src/tool/ftest"
"github.com/surdeus/goblin/src/tool/gfalse"
"github.com/surdeus/goblin/src/tool/grange"
"github.com/surdeus/goblin/src/tool/gtrue"
"github.com/surdeus/goblin/src/tool/in"
"github.com/surdeus/goblin/src/tool/ln"
"github.com/surdeus/goblin/src/tool/ls"
"github.com/surdeus/goblin/src/tool/mergelbl"
"github.com/surdeus/goblin/src/tool/mk"
"github.com/surdeus/goblin/src/tool/mkdir"
"github.com/surdeus/goblin/src/tool/noext"
"github.com/surdeus/goblin/src/tool/paths"
"github.com/surdeus/goblin/src/tool/quote"
"github.com/surdeus/goblin/src/tool/read"
"github.com/surdeus/goblin/src/tool/sort"
"github.com/surdeus/goblin/src/tool/tac"
"github.com/surdeus/goblin/src/tool/uniq"
"github.com/surdeus/goblin/src/tool/urlprs"
"github.com/surdeus/goblin/src/tool/useprog"
"github.com/surdeus/goblin/src/tool/wc"
"github.com/surdeus/goblin/src/tool/whoami"
"github.com/surdeus/goblin/src/tool/yes"
"github.com/surdeus/goblin/src/tool/script"
"github.com/mojosa-software/goblin/src/tool/awk"
"github.com/mojosa-software/goblin/src/tool/basename"
"github.com/mojosa-software/goblin/src/tool/cat"
"github.com/mojosa-software/goblin/src/tool/date"
"github.com/mojosa-software/goblin/src/tool/ec"
"github.com/mojosa-software/goblin/src/tool/echo"
"github.com/mojosa-software/goblin/src/tool/ftest"
"github.com/mojosa-software/goblin/src/tool/gfalse"
"github.com/mojosa-software/goblin/src/tool/grange"
"github.com/mojosa-software/goblin/src/tool/gtrue"
"github.com/mojosa-software/goblin/src/tool/in"
"github.com/mojosa-software/goblin/src/tool/ln"
"github.com/mojosa-software/goblin/src/tool/ls"
"github.com/mojosa-software/goblin/src/tool/mergelbl"
"github.com/mojosa-software/goblin/src/tool/mk"
"github.com/mojosa-software/goblin/src/tool/mkdir"
"github.com/mojosa-software/goblin/src/tool/noext"
"github.com/mojosa-software/goblin/src/tool/paths"
"github.com/mojosa-software/goblin/src/tool/quote"
"github.com/mojosa-software/goblin/src/tool/read"
"github.com/mojosa-software/goblin/src/tool/sort"
"github.com/mojosa-software/goblin/src/tool/tac"
"github.com/mojosa-software/goblin/src/tool/uniq"
"github.com/mojosa-software/goblin/src/tool/urlprs"
"github.com/mojosa-software/goblin/src/tool/useprog"
"github.com/mojosa-software/goblin/src/tool/wc"
"github.com/mojosa-software/goblin/src/tool/whoami"
"github.com/mojosa-software/goblin/src/tool/yes"
"github.com/mojosa-software/goblin/src/tool/script"
)
func main() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 119 KiB

View file

@ -93,12 +93,12 @@ if err != nil { ... }
Note that `INPUTMODE` and `OUTPUTMODE` set using `Vars` or in the `BEGIN` block will override these settings.
See the [full reference documentation](https://pkg.go.dev/github.com/surdeus/goblin/src/tool/awk/interp#Config) for the `interp.Config` struct.
See the [full reference documentation](https://pkg.go.dev/github.com/mojosa-software/goblin/src/tool/awk/interp#Config) for the `interp.Config` struct.
## Examples
Below are some examples using the [testdata/csv/states.csv](https://github.com/surdeus/goblin/src/tool/awk/blob/master/testdata/csv/states.csv) file, which is a simple CSV file whose contents are as follows:
Below are some examples using the [testdata/csv/states.csv](https://github.com/mojosa-software/goblin/src/tool/awk/blob/master/testdata/csv/states.csv) file, which is a simple CSV file whose contents are as follows:
```
"State","Abbreviation"
@ -278,7 +278,7 @@ NY
The [csvkit](https://csvkit.readthedocs.io/en/latest/index.html) suite is a set of tools that allow you to quickly analyze and extract fields from CSV files. Each csvkit tool allows you to do a specific task; GoAWK is more low-level and verbose, but also a more general tool ([`csvsql`](https://csvkit.readthedocs.io/en/latest/tutorial/3_power_tools.html#csvsql-and-sql2csv-ultimate-power) being the exception!). GoAWK also runs significantly faster than csvkit (the latter is written in Python).
Below are a few snippets showing how you'd do some of the tasks in the csvkit documentation, but using GoAWK (the input file is [testdata/csv/nz-schools.csv](https://github.com/surdeus/goblin/src/tool/awk/blob/master/testdata/csv/nz-schools.csv)):
Below are a few snippets showing how you'd do some of the tasks in the csvkit documentation, but using GoAWK (the input file is [testdata/csv/nz-schools.csv](https://github.com/mojosa-software/goblin/src/tool/awk/blob/master/testdata/csv/nz-schools.csv)):
### csvkit example: print column names
@ -363,7 +363,7 @@ $ goawk -i csv -H '/Girls/ { d+=@"Decile"; n++ } END { print d/n }' testdata/csv
The performance of GoAWK's CSV input and output mode is quite good, on a par with using the `encoding/csv` package from Go directly, and much faster than the `csv` module in Python. CSV input speed is significantly slower than `frawk`, though CSV output speed is significantly faster than `frawk`.
Below are the results of some simple read and write [benchmarks](https://github.com/surdeus/goblin/src/tool/awk/blob/master/scripts/csvbench) using `goawk` and `frawk` as well as plain Python and Go. The output of the write benchmarks is a 1GB, 3.5 million row CSV file with 20 columns (including quoted columns); the input for the read benchmarks uses that same file. Times are in seconds, showing the best of three runs on a 64-bit Linux laptop with an SSD drive:
Below are the results of some simple read and write [benchmarks](https://github.com/mojosa-software/goblin/src/tool/awk/blob/master/scripts/csvbench) using `goawk` and `frawk` as well as plain Python and Go. The output of the write benchmarks is a 1GB, 3.5 million row CSV file with 20 columns (including quoted columns); the input for the read benchmarks uses that same file. Times are in seconds, showing the best of three runs on a 64-bit Linux laptop with an SSD drive:
Test | goawk | frawk | Python | Go
--------------- | ----- | ----- | ------ | ----
@ -378,10 +378,10 @@ Writing 1GB CSV | 5.64 | 13.0 | 17.0 | 3.24
- keys would be ordered by `OFIELDS` (eg: `OFIELDS[1] = "name"; OFIELDS[2] = "age"`) or by "smart name" if `OFIELDS` not set ("smart name" meaning numeric if `a` keys are numeric, string otherwise)
- `printrow(a)` could take an optional second `fields` array arg to use that instead of the global `OFIELDS`
* Consider allowing `-H` to accept an optional list of field names which could be used as headers in the absence of headers in the file itself (either `-H=name,age` or `-i 'csv header=name,age'`).
* Consider adding TrimLeadingSpace CSV input option. See: https://github.com/surdeus/goblin/src/tool/awk/issues/109
* Consider adding TrimLeadingSpace CSV input option. See: https://github.com/mojosa-software/goblin/src/tool/awk/issues/109
* Consider supporting `@"id" = 42` named field assignment.
## Feedback
Please [open an issue](https://github.com/surdeus/goblin/src/tool/awk/issues) if you have bug reports or feature requests for GoAWK's CSV support.
Please [open an issue](https://github.com/mojosa-software/goblin/src/tool/awk/issues) if you have bug reports or feature requests for GoAWK's CSV support.

Binary file not shown.

View file

@ -38,11 +38,11 @@ import (
"strings"
"unicode/utf8"
"github.com/surdeus/goblin/src/tool/awk/interp"
"github.com/surdeus/goblin/src/tool/awk/lexer"
"github.com/surdeus/goblin/src/tool/awk/parser"
"github.com/mojosa-software/goblin/src/tool/awk/interp"
"github.com/mojosa-software/goblin/src/tool/awk/lexer"
"github.com/mojosa-software/goblin/src/tool/awk/parser"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
const (

View file

@ -18,8 +18,8 @@ import (
"sync"
"testing"
"github.com/surdeus/goblin/src/tool/awk/interp"
"github.com/surdeus/goblin/src/tool/awk/parser"
"github.com/mojosa-software/goblin/src/tool/awk/interp"
"github.com/mojosa-software/goblin/src/tool/awk/parser"
)
var (

View file

@ -7,7 +7,7 @@ import (
"strconv"
"strings"
. "github.com/surdeus/goblin/src/tool/awk/lexer"
. "github.com/mojosa-software/goblin/src/tool/awk/lexer"
)
// Program is an entire AWK program.

View file

@ -6,8 +6,8 @@ import (
"math"
"regexp"
"github.com/surdeus/goblin/src/tool/awk/internal/ast"
"github.com/surdeus/goblin/src/tool/awk/lexer"
"github.com/mojosa-software/goblin/src/tool/awk/internal/ast"
"github.com/mojosa-software/goblin/src/tool/awk/lexer"
)
// Program holds an entire compiled program.

View file

@ -7,8 +7,8 @@ import (
"io"
"strings"
"github.com/surdeus/goblin/src/tool/awk/internal/ast"
"github.com/surdeus/goblin/src/tool/awk/lexer"
"github.com/mojosa-software/goblin/src/tool/awk/internal/ast"
"github.com/mojosa-software/goblin/src/tool/awk/lexer"
)
// Disassemble writes a human-readable form of the program's virtual machine

View file

@ -9,8 +9,8 @@ import (
"fmt"
"strings"
"github.com/surdeus/goblin/src/tool/awk/interp"
"github.com/surdeus/goblin/src/tool/awk/parser"
"github.com/mojosa-software/goblin/src/tool/awk/interp"
"github.com/mojosa-software/goblin/src/tool/awk/parser"
)
func Example() {

View file

@ -12,8 +12,8 @@ import (
"strings"
"unicode/utf8"
"github.com/surdeus/goblin/src/tool/awk/internal/ast"
. "github.com/surdeus/goblin/src/tool/awk/lexer"
"github.com/mojosa-software/goblin/src/tool/awk/internal/ast"
. "github.com/mojosa-software/goblin/src/tool/awk/lexer"
)
// Call native-defined function with given name and arguments, return

View file

@ -13,8 +13,8 @@ import (
"testing"
"time"
"github.com/surdeus/goblin/src/tool/awk/interp"
"github.com/surdeus/goblin/src/tool/awk/parser"
"github.com/mojosa-software/goblin/src/tool/awk/interp"
"github.com/mojosa-software/goblin/src/tool/awk/parser"
)
func isFuzzTest(test interpTest) bool {

View file

@ -28,9 +28,9 @@ import (
"strings"
"unicode/utf8"
"github.com/surdeus/goblin/src/tool/awk/internal/ast"
"github.com/surdeus/goblin/src/tool/awk/internal/compiler"
"github.com/surdeus/goblin/src/tool/awk/parser"
"github.com/mojosa-software/goblin/src/tool/awk/internal/ast"
"github.com/mojosa-software/goblin/src/tool/awk/internal/compiler"
"github.com/mojosa-software/goblin/src/tool/awk/parser"
)
var (
@ -250,7 +250,7 @@ type Config struct {
// or "tsv" in Vars or in the BEGIN block (those override this setting).
//
// For further documentation about GoAWK's CSV support, see the full docs:
// https://github.com/surdeus/goblin/src/tool/awk/blob/master/csv.md
// https://github.com/mojosa-software/goblin/src/tool/awk/blob/master/csv.md
InputMode IOMode
// Additional options if InputMode is CSVMode or TSVMode. The zero value

View file

@ -18,8 +18,8 @@ import (
"sync"
"testing"
"github.com/surdeus/goblin/src/tool/awk/interp"
"github.com/surdeus/goblin/src/tool/awk/parser"
"github.com/mojosa-software/goblin/src/tool/awk/interp"
"github.com/mojosa-software/goblin/src/tool/awk/parser"
)
var (

View file

@ -17,8 +17,8 @@ import (
"strings"
"unicode/utf8"
"github.com/surdeus/goblin/src/tool/awk/internal/ast"
. "github.com/surdeus/goblin/src/tool/awk/lexer"
"github.com/mojosa-software/goblin/src/tool/awk/internal/ast"
. "github.com/mojosa-software/goblin/src/tool/awk/lexer"
)
// Print a line of output followed by a newline

View file

@ -6,7 +6,7 @@ import (
"context"
"math"
"github.com/surdeus/goblin/src/tool/awk/parser"
"github.com/mojosa-software/goblin/src/tool/awk/parser"
)
const checkContextOps = 1000 // for efficiency, only check context every N instructions

View file

@ -10,8 +10,8 @@ import (
"testing"
"time"
"github.com/surdeus/goblin/src/tool/awk/interp"
"github.com/surdeus/goblin/src/tool/awk/parser"
"github.com/mojosa-software/goblin/src/tool/awk/interp"
"github.com/mojosa-software/goblin/src/tool/awk/parser"
)
// This definitely doesn't test that everything was reset, but it's a good start.

View file

@ -10,15 +10,15 @@ import (
"strings"
"time"
"github.com/surdeus/goblin/src/tool/awk/internal/ast"
"github.com/surdeus/goblin/src/tool/awk/internal/compiler"
"github.com/surdeus/goblin/src/tool/awk/lexer"
"github.com/mojosa-software/goblin/src/tool/awk/internal/ast"
"github.com/mojosa-software/goblin/src/tool/awk/internal/compiler"
"github.com/mojosa-software/goblin/src/tool/awk/lexer"
)
// Execute a block of virtual machine instructions.
//
// A big switch seems to be the best way of doing this for now. I also tried
// an array of functions (https://github.com/surdeus/goblin/src/tool/awk/commit/8e04b069b621ff9b9456de57a35ff2fe335cf201)
// an array of functions (https://github.com/mojosa-software/goblin/src/tool/awk/commit/8e04b069b621ff9b9456de57a35ff2fe335cf201)
// and it was ever so slightly faster, but the code was harder to work with
// and it won't be improved when Go gets faster switches via jump tables
// (https://go-review.googlesource.com/c/go/+/357330/).
@ -1205,7 +1205,7 @@ func (p *interp) getline(redirect lexer.Token) (float64, string, error) {
if err != nil {
if _, ok := err.(*os.PathError); ok {
// File not found is not a hard error, getline just returns -1.
// See: https://github.com/surdeus/goblin/src/tool/awk/issues/41
// See: https://github.com/mojosa-software/goblin/src/tool/awk/issues/41
return -1, "", nil
}
return 0, "", err

View file

@ -8,7 +8,7 @@ import (
"strings"
"testing"
. "github.com/surdeus/goblin/src/tool/awk/lexer"
. "github.com/mojosa-software/goblin/src/tool/awk/lexer"
)
func TestLexer(t *testing.T) {

View file

@ -11,9 +11,9 @@ import (
"strconv"
"strings"
"github.com/surdeus/goblin/src/tool/awk/internal/ast"
"github.com/surdeus/goblin/src/tool/awk/internal/compiler"
. "github.com/surdeus/goblin/src/tool/awk/lexer"
"github.com/mojosa-software/goblin/src/tool/awk/internal/ast"
"github.com/mojosa-software/goblin/src/tool/awk/internal/compiler"
. "github.com/mojosa-software/goblin/src/tool/awk/lexer"
)
// ParseError (actually *ParseError) is the type of error returned by

View file

@ -8,7 +8,7 @@ import (
"strings"
"testing"
"github.com/surdeus/goblin/src/tool/awk/parser"
"github.com/mojosa-software/goblin/src/tool/awk/parser"
)
// NOTE: apart from TestParseAndString, the parser doesn't have

View file

@ -7,8 +7,8 @@ import (
"reflect"
"sort"
"github.com/surdeus/goblin/src/tool/awk/internal/ast"
. "github.com/surdeus/goblin/src/tool/awk/lexer"
"github.com/mojosa-software/goblin/src/tool/awk/internal/ast"
. "github.com/mojosa-software/goblin/src/tool/awk/lexer"
)
type varType int

View file

@ -1,13 +1,13 @@
# GoAWK: an AWK interpreter with CSV support
[![Documentation](https://pkg.go.dev/badge/github.com/surdeus/goblin/src/tool/awk)](https://pkg.go.dev/github.com/surdeus/goblin/src/tool/awk)
[![GitHub Actions Build](https://github.com/surdeus/goblin/src/tool/awk/workflows/Go/badge.svg)](https://github.com/surdeus/goblin/src/tool/awk/actions?query=workflow%3AGo)
[![Documentation](https://pkg.go.dev/badge/github.com/mojosa-software/goblin/src/tool/awk)](https://pkg.go.dev/github.com/mojosa-software/goblin/src/tool/awk)
[![GitHub Actions Build](https://github.com/mojosa-software/goblin/src/tool/awk/workflows/Go/badge.svg)](https://github.com/mojosa-software/goblin/src/tool/awk/actions?query=workflow%3AGo)
AWK is a fascinating text-processing language, and somehow after reading the delightfully-terse [*The AWK Programming Language*](https://ia802309.us.archive.org/25/items/pdfy-MgN0H1joIoDVoIC7/The_AWK_Programming_Language.pdf) I was inspired to write an interpreter for it in Go. So here it is, feature-complete and tested against "the one true AWK" and GNU AWK test suites.
GoAWK is a POSIX-compatible version of AWK, and additionally has a CSV mode for reading and writing CSV and TSV files. This feature was sponsored by the [library of the University of Antwerp](https://www.uantwerpen.be/en/library/). Read the [CSV documentation](https://github.com/surdeus/goblin/src/tool/awk/blob/master/csv.md).
GoAWK is a POSIX-compatible version of AWK, and additionally has a CSV mode for reading and writing CSV and TSV files. This feature was sponsored by the [library of the University of Antwerp](https://www.uantwerpen.be/en/library/). Read the [CSV documentation](https://github.com/mojosa-software/goblin/src/tool/awk/blob/master/csv.md).
You can also read one of the articles I've written about GoAWK:
@ -21,7 +21,7 @@ You can also read one of the articles I've written about GoAWK:
To use the command-line version, simply use `go install` to install it, and then run it using `goawk` (assuming `~/go/bin` is in your `PATH`):
```shell
$ go install github.com/surdeus/goblin/src/tool/awk@latest
$ go install github.com/mojosa-software/goblin/src/tool/awk@latest
$ goawk 'BEGIN { print "foo", 42 }'
foo 42
@ -82,9 +82,9 @@ if err != nil {
// 3:abc
```
If you need to repeat execution of the same program on different inputs, you can call [`interp.New`](https://pkg.go.dev/github.com/surdeus/goblin/src/tool/awk/interp#New) once, and then call the returned object's `Execute` method as many times as you need.
If you need to repeat execution of the same program on different inputs, you can call [`interp.New`](https://pkg.go.dev/github.com/mojosa-software/goblin/src/tool/awk/interp#New) once, and then call the returned object's `Execute` method as many times as you need.
Read the [package documentation](https://pkg.go.dev/github.com/surdeus/goblin/src/tool/awk) for more details.
Read the [package documentation](https://pkg.go.dev/github.com/mojosa-software/goblin/src/tool/awk) for more details.
## Differences from AWK
@ -93,7 +93,7 @@ The intention is for GoAWK to conform to `awk`'s behavior and to the [POSIX AWK
Additional features GoAWK has over AWK:
* It has proper support for CSV and TSV files ([read the documentation](https://github.com/surdeus/goblin/src/tool/awk/blob/master/csv.md)).
* It has proper support for CSV and TSV files ([read the documentation](https://github.com/mojosa-software/goblin/src/tool/awk/blob/master/csv.md)).
* It supports negative field indexes to access fields from the right, for example, `$-1` refers to the last field.
* It's embeddable in your Go programs! You can even call custom Go functions from your AWK scripts.
* Most AWK scripts are faster than `awk` and on a par with `gawk`, though usually slower than `mawk`. (See [recent benchmarks](https://benhoyt.com/writings/goawk-compiler-vm/#virtual-machine-results).)
@ -112,12 +112,12 @@ This project has a good suite of tests, which include my own intepreter tests, t
## AWKGo
The GoAWK repository also includes the creatively-named AWKGo, an AWK-to-Go compiler. This is experimental and is not subject to the stability requirements of GoAWK itself. You can [read more about AWKGo](https://benhoyt.com/writings/awkgo/) or browse the code on the [`awkgo` branch](https://github.com/surdeus/goblin/src/tool/awk/tree/awkgo/awkgo).
The GoAWK repository also includes the creatively-named AWKGo, an AWK-to-Go compiler. This is experimental and is not subject to the stability requirements of GoAWK itself. You can [read more about AWKGo](https://benhoyt.com/writings/awkgo/) or browse the code on the [`awkgo` branch](https://github.com/mojosa-software/goblin/src/tool/awk/tree/awkgo/awkgo).
## License
GoAWK is licensed under an open source [MIT license](https://github.com/surdeus/goblin/src/tool/awk/blob/master/LICENSE.txt).
GoAWK is licensed under an open source [MIT license](https://github.com/mojosa-software/goblin/src/tool/awk/blob/master/LICENSE.txt).
## The end

Binary file not shown.

View file

@ -4,7 +4,7 @@ package basename
import(
"fmt"
"path"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
var(

View file

@ -4,7 +4,7 @@ import(
"os"
"io"
"fmt"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
var(

View file

@ -3,7 +3,7 @@ package date
import(
"fmt"
"time"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
func Run(flagSet *mtool.Flags) {

View file

@ -6,7 +6,7 @@ import(
"os"
"bufio"
"log"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
const(

View file

@ -3,7 +3,7 @@ package echo
import (
"fmt"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
var(

View file

@ -5,7 +5,7 @@ import (
"io"
"bufio"
"fmt"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
"path/filepath"
)

View file

@ -2,7 +2,7 @@ package gfalse
import(
"os"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
func Run(flags *mtool.Flags) {

View file

@ -3,7 +3,7 @@ package grange
import(
"fmt"
"strconv"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
var(

View file

@ -1,5 +1,5 @@
package gtrue
import "github.com/surdeus/gomtool/src/mtool"
import "github.com/mojosa-software/gomtool/src/mtool"
func Run(flags *mtool.Flags) {}

View file

@ -5,7 +5,7 @@ import (
"io"
"bufio"
"fmt"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
func Run(flagSet *mtool.Flags) {

View file

@ -3,7 +3,7 @@ package ln
import (
"fmt"
"os"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
"path/filepath"
)

View file

@ -5,7 +5,7 @@ import(
"strings"
"regexp"
"path"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
var(

View file

@ -5,7 +5,7 @@ import(
"fmt"
"bufio"
"log"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
func Run(flagSet *mtool.Flags) {

View file

@ -9,8 +9,8 @@ import (
"strings"
"sync"
"github.com/surdeus/goblin/src/pathx"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/goblin/src/pathx"
"github.com/mojosa-software/gomtool/src/mtool"
)
// True if messages should be printed without fancy colors.

View file

@ -11,7 +11,7 @@ import (
"regexp"
"strings"
"github.com/surdeus/goblin/src/pathx"
"github.com/mojosa-software/goblin/src/pathx"
)
type parser struct {

View file

@ -5,7 +5,7 @@ import (
"os"
"path/filepath"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
func Run(flagSet *mtool.Flags) {

View file

@ -3,7 +3,7 @@ package noext
import(
"fmt"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
var(

View file

@ -9,9 +9,9 @@ import (
"path"
"strings"
//"github.com/surdeus/goblin/src/pathx"
//"github.com/mojosa-software/goblin/src/pathx"
"path/filepath"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
var (

View file

@ -7,7 +7,7 @@ import(
"fmt"
"unicode"
"bufio"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
func HasWhiteSpace(s string) bool {

View file

@ -4,7 +4,7 @@ import(
"os"
"bufio"
"fmt"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
var(

View file

@ -11,12 +11,12 @@ import (
"os"
"strings"
"github.com/surdeus/goscript/core"
"github.com/surdeus/goscript/env"
_ "github.com/surdeus/goscript/packages"
"github.com/surdeus/goscript/parser"
"github.com/surdeus/goscript/vm"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/goscript/core"
"github.com/mojosa-software/goscript/env"
_ "github.com/mojosa-software/goscript/packages"
"github.com/mojosa-software/goscript/parser"
"github.com/mojosa-software/goscript/vm"
"github.com/mojosa-software/gomtool/src/mtool"
"os/exec"
//"bytes"
)
@ -53,7 +53,6 @@ func (o Output) Split(sep string) []string {
return strings.Split(o.String(), sep)
}
func Run(flagSet *mtool.Flags) {
printVersion := flagSet.Bool("v", false, "prints out the version and then exits")

View file

@ -4,8 +4,8 @@ import (
"fmt"
"os"
"sort"
"github.com/surdeus/goblin/src/input"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/goblin/src/input"
"github.com/mojosa-software/gomtool/src/mtool"
)
func Run(flagSet *mtool.Flags) {

View file

@ -5,7 +5,7 @@ import(
"io"
"fmt"
"bufio"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
func reverse(a []string) chan string {

View file

@ -6,7 +6,7 @@ import(
"fmt"
"bufio"
"io"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
func Run(flagSet *mtool.Flags) {

View file

@ -5,7 +5,7 @@ import (
"fmt"
"net"
"net/url"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
var nilStr = "_"

View file

@ -4,7 +4,7 @@ import (
"os"
"os/exec"
"fmt"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
"path/filepath"
)

View file

@ -7,7 +7,7 @@ import (
"fmt"
"unicode"
"strconv"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
var (

View file

@ -5,7 +5,7 @@ import(
"os/user"
"fmt"
"log"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/gomtool/src/mtool"
)
func Run(flagSet *mtool.Flags) {

View file

@ -5,8 +5,8 @@ import(
"os"
"fmt"
"strings"
"github.com/surdeus/goblin/src/input"
"github.com/surdeus/gomtool/src/mtool"
"github.com/mojosa-software/goblin/src/input"
"github.com/mojosa-software/gomtool/src/mtool"
)
var(
nArg int