# Golang build tags in fly.toml file

**URL:** <https://community.fly.io/t/golang-build-tags-in-fly-toml-file/9681>\
**Category:** Questions / Help\
**Tags:** login-only\
**Created:** [December 28, 2022, 3:27pm UTC](https://community.fly.io/t/golang-build-tags-in-fly-toml-file/9681 "2022-12-28T15:27:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![indiependente](https://avatars.discourse-cdn.com/v4/letter/i/b3f665/32.png) [@indiependente](https://community.fly.io/u/indiependente)\
**Post date:** [December 28, 2022, 3:27pm UTC](https://community.fly.io/t/golang-build-tags-in-fly-toml-file/9681/1 "2022-12-28T15:27:28Z")

</div>

Hi all,

I’ve been trying to build a Go app that requires some build tags, e.g.

```auto
go build -tags "tag1" -o app

```

but so far I haven’t been able to pass such tags to the build command executed by the builder.

Here is the configuration I have in the fly.toml file:

```auto
# fly.toml
[build]
  builder = "paketobuildpacks/builder:base"
  buildpacks = ["gcr.io/paketo-buildpacks/go"]
  [[build.env]]
    name="BP_GO_BUILD_LDFLAGS"
    value="-s -w"
  [[build.env]]
    name="BP_GO_BUILD_FLAGS"
    value="-tags=prod"

```

Can someone advise on what’s the best way to pass such flags to the build command?  
Thanks.

P.S.  
I could deploy this app as a minimal Dockerised app, is there any performance benefit in preferring a Go app over a Dockerised app? Thanks

---

<div class="post-metadata">

**Author:** ![tvdfly](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/tvdfly/32/4297_2.png) [@tvdfly](https://community.fly.io/u/tvdfly)\
**Post date:** [December 28, 2022, 9:19pm UTC](https://community.fly.io/t/golang-build-tags-in-fly-toml-file/9681/2 "2022-12-28T21:19:54Z")

</div>

Try `[build.args]` instead of `[[build.env]]`. For example:

```toml
[build.args]
  BP_GO_BUILD_LDFLAGS ="-s -w"
  BP_GO_BUILD_FLAGS ="-tags=prod"

```

> **[Fly Launch configuration (fly.toml)](https://fly.io/docs/reference/configuration/#specify-docker-build-arguments)**
>
> Documentation and guides from the team at Fly.io.

> [@indiependente](#):
>
> I could deploy this app as a minimal Dockerised app, is there any performance benefit in preferring a Go app over a Dockerised app?

Using a dockerfile will probably make for faster builds and deployments. The buildpack images are pretty big since they include a lot of different tools, which can make them slower to download during builds and deploys.

I don’t think there will be much if any difference in the performance of the application once it is deployed.

---

<div class="post-metadata">

**Author:** ![indiependente](https://avatars.discourse-cdn.com/v4/letter/i/b3f665/32.png) [@indiependente](https://community.fly.io/u/indiependente)\
**Post date:** [December 28, 2022, 9:32pm UTC](https://community.fly.io/t/golang-build-tags-in-fly-toml-file/9681/3 "2022-12-28T21:32:59Z")

</div>

Thanks @tvdfly! I can confirm it works!

> Using a dockerfile will probably make for faster builds and deployments. The buildpack images are pretty big since they include a lot of different tools, which can make them slower to download during builds and deploys.  
> I don’t think there will be much if any difference in the performance of the application once it is deployed.

I think I’ll probably move to the Dockerised app then, just to shave off some time during deployments.  
As you said, I noticed as well that the buildpack image for the same app is about 100MB+ while my own is ~12MB.

Thanks again.

---

<div class="post-metadata">

**Author:** ![catflydotio](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/catflydotio/32/14559_2.png) [@catflydotio](https://community.fly.io/u/catflydotio)\
**Post date:** [April 27, 2024, 12:22am UTC](https://community.fly.io/t/golang-build-tags-in-fly-toml-file/9681/4 "2024-04-27T00:22:53Z")

</div>

Category updated on April 27, 2024, 12:22am UTC

From #How To to #Questions / Help

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/fly1/original/3X/6/e/6e8955d00cb218e186ebbe3a6ab06fefdce15290.svg) [@system](https://community.fly.io/u/system)\
**Post date:** [May 4, 2024, 12:23am UTC](https://community.fly.io/t/golang-build-tags-in-fly-toml-file/9681/5 "2024-05-04T00:23:37Z")

</div>

Closed on May 4, 2024, 12:23am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
