GeertJohan / GeertJohan/go.rice

Cannot specify build flags to detect correct file for `rice embed-go`

Open
#56 1 comment 0 reactions 1 assignee Claimed by @GeertJohan View on GitHub
enhancement
Dominant language
Go
Stars
2.4k
Forks
185
PR merge metrics
No merged PRs in 30d

Description

I have two files:

js_asset_prod.go:

``` go
// +build production

package server

import (
"github.com/GeertJohan/go.rice"
)

var javascriptAssetRiceBox = rice.MustFindBox("./js/prod").HTTPBox() // <--- prod path
```

and js_asset_dev.go:

``` go
// +build !production

package server

import (
"github.com/GeertJohan/go.rice"
)

var javascriptAssetRiceBox = rice.MustFindBox("./js/dev").HTTPBox() // <-- dev path
```

And when I run `rice -v -i ./server/ embed-go` I get output like:

```
2015/05/06 23:50:17 skipping file "~/server/js-dev.rice-box.go"
2015/05/06 23:50:17 scanning file "~/server/js_asset_dev.go"
2015/05/06 23:50:17 found box "js/dev"
2015/05/06 23:50:17 scanning file "~/server/server.go"
2015/05/06 23:50:17
2015/05/06 23:50:17 embedding box 'js/dev'
2015/05/06 23:50:17 to file js-dev.rice-box.go
2015/05/06 23:50:17 includes dir: ''
2015/05/06 23:50:17
2015/05/06 23:50:17 rice finished successfully
```

It appears that rice does not recognize js_asset_prod.go because it has an opt-in build flag, and in go.rice/flags.go, it uses `build.ImportDir` which does not support adding build flags (and the rice CLI does not support adding build flags either).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.