Exclude a directory from go build

8,468 views
Skip to first unread message

Subhajit Datta

unread,
Mar 26, 2015, 5:27:30 AM3/26/15
to golan...@googlegroups.com
Hi,
Is there a way I can exclude a directory path from go build?

Regards,
Subhajit Datta

Jan Mercl

unread,
Mar 26, 2015, 5:57:46 AM3/26/15
to golan...@googlegroups.com
On Thu, Mar 26, 2015 at 10:27 AM Subhajit Datta <subhaji...@jabong.com> wrote:

> Is there a way I can exclude a directory path from go build?

Please let us know what problem you're solving. go build normally (not in the ./... case) considers directories when they're needed because something depends on the packages in them. Excluding those directories would thus probably mean that the build cannot succeed.

If you are perhaps looking for how to not build examples, then one can use // +build ignore lines instead.

-j

Subhajit Datta

unread,
Mar 26, 2015, 6:15:40 AM3/26/15
to golan...@googlegroups.com
@Jan

I have a project directory structure as :


<project_root>
    bin/
    config/
    deploy/
    docs/
    pkg/
    src/
    libs/
    makefile

in my makefile i set GOPATH=<project_root>:<project_root>/libs/
GOBIN=<project_root>/bin

All my code is under src/
The external libs are added inside <project_root>/libs/src/github.com/ and so on.
Now while go install at the project root all the libs/ are also build and the binaries are created and add in my bin/
I just want that go build ./... should  not try to compile and build the external libs.
Same got go test ./... should only run all the tests under src/

I have the checkin the external libs as part of my <project> since I could not find a better way to manage the dependencies
So basically, I want to seperate out the external libs/ from my src/.

I hope I could explain my problem.

Please provide your suggestions.

John Souvestre

unread,
Mar 26, 2015, 6:17:19 AM3/26/15
to Subhajit Datta, golan...@googlegroups.com

I believe that if the directory name starts with an underscore (_) that build will ignore it.

 

John

    John Souvestre - New Orleans LA

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave Cheney

unread,
Mar 26, 2015, 6:24:06 AM3/26/15
to golan...@googlegroups.com, subhaji...@jabong.com
Or a period, or the word "testdata"

Subhajit Datta

unread,
Mar 26, 2015, 6:32:46 AM3/26/15
to golan...@googlegroups.com
Hi that _ worked.
Not sure if "testdata" as suggested by @dave will work
Surely the period will work, but will not want to make the folder hidden in linux.


On Thursday, March 26, 2015 at 2:57:30 PM UTC+5:30, Subhajit Datta wrote:
Reply all
Reply to author
Forward
0 new messages