DAddYE/igo
{ "createdAt": "2014-03-15T00:43:49Z", "defaultBranch": "master", "description": "Intermediate GoLang source representation", "fullName": "DAddYE/igo", "homepage": "http://play.igolang.io", "language": "Go", "name": "igo", "pushedAt": "2014-04-03T17:04:40Z", "stargazersCount": 138, "topics": [], "updatedAt": "2025-09-04T02:21:13Z", "url": "https://github.com/DAddYE/igo"}iGo, Intermediate Golang
Section titled “iGo, Intermediate Golang”This project provides an intermediate source representation of go source files.
Most of the code comes directly from the standard library of pkg/go however the core part, parser
and scanner has been heavily modified, the igo ast instead is pretty much unchanged to allow
an easily swap with the original one.
The aim of this project is to provide an alternative go fmt which means the you will be able
to write as you like and then distribute in the standard go way (*.go formatted files).
It’s in beta stage
How it works?
Section titled “How it works?”You can TRY IT on play.igolang.io or with the cli:
usage: igo [compile|parse|build] [flags] [path ...] -comments=true: print comments -dest="": destination directory -tabs=true: indent with tabs -tabwidth=8: tab width$ igo parse # will convert any *.go file in *.igo$ igo compile # will convert *.igo source code in *.goNote that build currently is not yet implemented.
Manually convert go code:
Section titled “Manually convert go code:”import "bytes" "fmt" "github.com/DAddYE/igo/from_go" "go/parser" "go/token" "io/ioutil" "log" "testing"
func ExampleFromGo() # Initialize the scanner. fset := token.NewFileSet() # positions are relative to fset
const filename = "../ast/ast.go"
src, err := ioutil.ReadFile(filename) if err != nil log.Fatalf("%s", err)
file, err := parser.ParseFile(fset, filename, src, parser.ParseComments) if err != nil fmt.Println(err) return
# Print the function body into buffer buf. # The file set is provided to the printer so that it knows # about the original source formatting and can add additional # line breaks where they were present in the source. var buf bytes.Buffer from_go.Fprint(&buf, fset, file)
# Print the cleaned-up body text to stdout. fmt.Println(&buf)Manually convert iGo code:
Section titled “Manually convert iGo code:”import "bytes" "fmt" "github.com/DAddYE/igo/parser" "github.com/DAddYE/igo/to_go" "github.com/DAddYE/igo/token" "io/ioutil" "log" "testing"
func ExampleToGo() # Initialize the scanner. fset := token.NewFileSet() # positions are relative to fset
const filename = "../ast/ast.igo"
src, err := ioutil.ReadFile(filename) if err != nil log.Fatalf("%s", err)
file, err := parser.ParseFile(fset, filename, src, parser.ParseComments) if err != nil fmt.Println(err) return
# Print the function body into buffer buf. # The file set is provided to the printer so that it knows # about the original source formatting and can add additional # line breaks where they were present in the source. var buf bytes.Buffer to_go.Fprint(&buf, fset, file)
# Print the cleaned-up body text to stdout. fmt.Println(&buf)How looks like?
Section titled “How looks like?”Just browse *.igo files, but soon I’ll make a ebnf notation.
What will change?
Section titled “What will change?”Pretty much really few things, golang itself is almost perfect, this parser will allow you to skip
some annoyance. Nothing more.
Editors
Section titled “Editors”- Vim
- add yours …
What’s left?
Section titled “What’s left?”In my roadmap there is:
- Builds (aka
igo build|run|test) - Add GoCode like for editors
- iGo format (aka
igo fmt) - iGo doc (aka
igo doc) - Expose
ast(akalittle macros) - Expose
__filename__,__fname__
Other info
Section titled “Other info”This project was partially influenced by Nimrod which I highly suggest to try.
License MIT/BSD-style
Section titled “License MIT/BSD-style”Author Davide D’Agostino (@DAddYE) and The Go Authors