jteeuwen/go-bindata — pull request #37 by rjeczalik (2014-06-25 22:55:19+00:00)
Title: Automagically convert files in $GOPATH/data

Hi @jteeuwen!

I've just had too much time I thought I'd throw some magic at your `go-bindata`. And by coincidence it actually happened that I had pretty solid use-case to leverage this functionality. If you'd happen to like it, it'd be awesome if you'd merged it with your project. Below I paste some description:

### Automagic conversion within `$GOPATH` workspace

When no input files nor directories are provided via command line flags,
go-bindata reads `$GOPATH` workspaces and attempts to convert all files it
finds recursively in `$GOPATH/data`, generating a `bindata.go` file in a matching
`$GOPATH/src` directory. The match is always the longest path diff between
`$GOPATH/data` and `$GOPATH/src`, in order to avoid having assets which content
overlaps. For example, running:

```bash
~ $ GOPATH=/home/user go-bindata
```

over the following $GOPATH workspace:

```bash
/home/user
├── data
│ ├── bitbucket.org
│ │ └── user
│ │ └── hidden
│ │ └── subpackage
│ │ ├── aws.txt
│ │ └── pass.txt
│ └── github.com
│ └── user
│ └── example
│ └── assets
│ ├── css
│ │ └── default.css
│ └── js
│ ├── app.js
│ └── link.js
└── src
├── bitbucket.org
│ └── user
│ └── hidden
│ ├── hidden.go
│ └── subpackage
│ └── subpackage.go
└── github.com
└── user
└── example
└── example.go
```

will create two asset files under the following paths:

```bash
~ $ GOPATH=/home/user go-bindata
ok bitbucket.org/user/hidden/subpackage (/home/user/src/bitbucket.org/user/hidden/subpackage/bindata.go) 0.001s
ok github.com/user/example (/home/user/src/github.com/user/example/bindata.go) 0.002s
```

Running go-bindata in this mode will ignore any values passed by `-o`, `-pkg` and
`-prefix` flags.