Skip to content

Commit

Permalink
Cross compilation works
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmartinelli committed Aug 17, 2015
1 parent c3477af commit 32df737
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 31 deletions.
9 changes: 9 additions & 0 deletions README.md
Expand Up @@ -133,3 +133,12 @@ Run import regression tests against the samples.
```bash
./test.sh
```

## Cross-compiling

We use [gox](https://github.com/mitchellh/gox) to create distributable
binaries for Windows, OSX and Linux.

```bash
docker run --rm -v "$(pwd)":/usr/src/pgfutter -w /usr/src/pgfutter tcnksm/gox:1.4.2-light
```
29 changes: 0 additions & 29 deletions lib/json.go

This file was deleted.

16 changes: 14 additions & 2 deletions pgfutter.go
@@ -1,8 +1,10 @@
package main

import (
"bufio"
"database/sql"
"encoding/csv"
"encoding/json"
"fmt"
"io"
"log"
Expand All @@ -13,7 +15,6 @@ import (

"github.com/codegangsta/cli"
"github.com/lib/pq"
"github.com/lukasmartinelli/pgfutter/lib"
)

func postgresify(identifier string) string {
Expand Down Expand Up @@ -42,6 +43,17 @@ func failOnError(err error, msg string) {
}
}

func ImportJson(c *cli.Context) {
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
var record map[string]interface{}
value := scanner.Text()
err := json.Unmarshal([]byte(value), &record)
failOnError(err, "Could not unmarshal")
}
failOnError(scanner.Err(), "Could not parse")
}

func connect(connStr string, importSchema string) *sql.DB {
db, err := sql.Open("postgres", connStr)
failOnError(err, "Could not prepare connection to database")
Expand Down Expand Up @@ -227,7 +239,7 @@ func main() {
{
Name: "json",
Usage: "Import JSON objects into database",
Action: lib.ImportJson,
Action: ImportJson,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "flatten-graph, flatten",
Expand Down

0 comments on commit 32df737

Please sign in to comment.