• Stars
    star
    142
  • Rank 258,495 (Top 6 %)
  • Language
    Go
  • Created over 10 years ago
  • Updated over 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Intermediate GoLang source representation

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?

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 *.go

Note that build currently is not yet implemented.

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:

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?

Just browse *.igo files, but soon I'll make a ebnf notation.

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

  • Vim
  • add yours ...

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 (aka little macros)
  • Expose __filename__, __fname__

Other info

This project was partially influenced by Nimrod which I highly suggest to try.

License MIT/BSD-style

Author Davide D'Agostino (@DAddYE) and The Go Authors

More Repositories

1

foreverb

Small daemon framework for ruby, with logging, error handler, scheduling and much more.
Ruby
520
star
2

vips

Go Bindings for Vips (a super fast image processor)
Go
450
star
3

mini_record

ActiveRecord meets DataMapper, with MiniRecord you are be able to write schema inside your models.
Ruby
265
star
4

do

DO - IT! is a thin framework useful to manage remote servers through ssh.
Ruby
166
star
5

leveldb

LevelDB for Ruby (embedded)
Ruby
126
star
6

lipsiadmin

Lipsiadmin is a new revolutionary admin for your projects. Lipsiadmin is based on Ext Js 3+. framework (with prototype adapter) and is ready for Rails 2.+. This admin is for newbie developper but also for experts, is not entirely written in javascript because the aim of developper wose build in a agile way web/site apps so we use extjs in a new intelligent way a mixin of β€œold” html and new ajax functions, for example ext manage the layout of page, grids, tree and errors, but form are in html code.
Ruby
105
star
7

trez

A fast image resizer
Go
102
star
8

githubwatcher

Github Growl Watcher, watch any project and get instant growl notifications for: updates, new watchers, forks and issues
Ruby
88
star
9

lightbox

LightBox Helper is a small but beautifull helper that automatize the process for include LightBox on our pages.
JavaScript
39
star
10

ruby_nsq

Ruby client for the NSQ realtime message processing system
Ruby
28
star
11

gruby

Go lang to Ruby transpiler
Go
26
star
12

soda.vim

Reinterpreted Soda Theme for Vim Users
Vim Script
21
star
13

lipsiablog

Lightweight, simple, fast, easy blogging engine written in rails and Lipsiadmin
JavaScript
17
star
14

exception-notifier

Exception Notifier Plugin for Rails, that send email notification and generate error pages that you can use with your controller Layout.
Ruby
13
star
15

google_tasks

This gem provides access to google tasks apis
Ruby
10
star
16

model

Naive sql to struct for go
Go
8
star
17

node.nim

Work in progress node pattern on the awesome Nimrod
Nim
7
star
18

goroutine

Simple goroutine model for Ruby.
Ruby
6
star
19

fiddler

Wrapper for Fiddler (Ruby 2.0 FFI impl)
Ruby
6
star
20

ruvy

FFI Bindings to Libuv (experimental)
Ruby
6
star
21

eva

Effortless event driven micro framework that runs on Ruby in a different syntax
Ruby
6
star
22

golia

WebSite Link and Speed Checker
Ruby
5
star
23

documents

Document nubble FS
Ruby
4
star
24

tomorrow.vim

Dark light version of new Tomorrow Theme
Vim Script
4
star
25

.vim

My vim editor, plugins, syntax and more.
Vim Script
3
star
26

forever

MOVED HERE: https://github.com/DAddYE/foreverb
3
star
27

wintersmith-perian

Browserify, Coffee, Stylus, UglifyJS and CleanCSS
CoffeeScript
3
star
28

gist

Repo as a gist
Nim
3
star
29

loop

A tiny Ruby program used to periodically execute a command.
Ruby
2
star
30

snippets

Snipmate custom snippets
2
star
31

.do

My Servo recipes
Ruby
1
star
32

yarv

RubyVM (yarv) compiler/decompiler, written in go.
Go
1
star
33

rosetta

One language to rule them all.
Ruby
1
star
34

homebrew-alt

My homebrews
Ruby
1
star
35

mrb

FFI bindings for mruby
Ruby
1
star
36

uv

Ruby bindings for libuv
Ruby
1
star
37

lipsiadmin-I18n

Repository for collecting Locale data for Lipsiadmin
1
star
38

igo.vim

Vim syntax for igo
Vim Script
1
star
39

coding-style

Coding style
1
star