Go build error: no non-test Go files in











up vote
2
down vote

favorite












Getting an error when trying to run go build ./... from my $GOPATH/src .



no non-test Go files in <dir>


The error is correct there are no test files in <dir> but why is that causing a compile error? Is it a bug?










share|improve this question






















  • The error says there are no non-test files. There's nothing to build in that directory.
    – JimB
    Oct 23 '17 at 21:54












  • "from my $GOPATH/src" that doesn't sound right - that builds everything - what are you trying to build?
    – fstanis
    Oct 23 '17 at 22:27










  • @fstanis everything
    – Clintm
    Oct 23 '17 at 22:27










  • You are aware that go build ./... doesn't do anything, other than building things and throwing away the results, right?
    – JimB
    Oct 23 '17 at 22:44










  • @JimB go install ./... exits with the same error
    – Clintm
    Oct 23 '17 at 22:46















up vote
2
down vote

favorite












Getting an error when trying to run go build ./... from my $GOPATH/src .



no non-test Go files in <dir>


The error is correct there are no test files in <dir> but why is that causing a compile error? Is it a bug?










share|improve this question






















  • The error says there are no non-test files. There's nothing to build in that directory.
    – JimB
    Oct 23 '17 at 21:54












  • "from my $GOPATH/src" that doesn't sound right - that builds everything - what are you trying to build?
    – fstanis
    Oct 23 '17 at 22:27










  • @fstanis everything
    – Clintm
    Oct 23 '17 at 22:27










  • You are aware that go build ./... doesn't do anything, other than building things and throwing away the results, right?
    – JimB
    Oct 23 '17 at 22:44










  • @JimB go install ./... exits with the same error
    – Clintm
    Oct 23 '17 at 22:46













up vote
2
down vote

favorite









up vote
2
down vote

favorite











Getting an error when trying to run go build ./... from my $GOPATH/src .



no non-test Go files in <dir>


The error is correct there are no test files in <dir> but why is that causing a compile error? Is it a bug?










share|improve this question













Getting an error when trying to run go build ./... from my $GOPATH/src .



no non-test Go files in <dir>


The error is correct there are no test files in <dir> but why is that causing a compile error? Is it a bug?







go build compiler-errors






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Oct 23 '17 at 21:52









Clintm

2,01221933




2,01221933












  • The error says there are no non-test files. There's nothing to build in that directory.
    – JimB
    Oct 23 '17 at 21:54












  • "from my $GOPATH/src" that doesn't sound right - that builds everything - what are you trying to build?
    – fstanis
    Oct 23 '17 at 22:27










  • @fstanis everything
    – Clintm
    Oct 23 '17 at 22:27










  • You are aware that go build ./... doesn't do anything, other than building things and throwing away the results, right?
    – JimB
    Oct 23 '17 at 22:44










  • @JimB go install ./... exits with the same error
    – Clintm
    Oct 23 '17 at 22:46


















  • The error says there are no non-test files. There's nothing to build in that directory.
    – JimB
    Oct 23 '17 at 21:54












  • "from my $GOPATH/src" that doesn't sound right - that builds everything - what are you trying to build?
    – fstanis
    Oct 23 '17 at 22:27










  • @fstanis everything
    – Clintm
    Oct 23 '17 at 22:27










  • You are aware that go build ./... doesn't do anything, other than building things and throwing away the results, right?
    – JimB
    Oct 23 '17 at 22:44










  • @JimB go install ./... exits with the same error
    – Clintm
    Oct 23 '17 at 22:46
















The error says there are no non-test files. There's nothing to build in that directory.
– JimB
Oct 23 '17 at 21:54






The error says there are no non-test files. There's nothing to build in that directory.
– JimB
Oct 23 '17 at 21:54














"from my $GOPATH/src" that doesn't sound right - that builds everything - what are you trying to build?
– fstanis
Oct 23 '17 at 22:27




"from my $GOPATH/src" that doesn't sound right - that builds everything - what are you trying to build?
– fstanis
Oct 23 '17 at 22:27












@fstanis everything
– Clintm
Oct 23 '17 at 22:27




@fstanis everything
– Clintm
Oct 23 '17 at 22:27












You are aware that go build ./... doesn't do anything, other than building things and throwing away the results, right?
– JimB
Oct 23 '17 at 22:44




You are aware that go build ./... doesn't do anything, other than building things and throwing away the results, right?
– JimB
Oct 23 '17 at 22:44












@JimB go install ./... exits with the same error
– Clintm
Oct 23 '17 at 22:46




@JimB go install ./... exits with the same error
– Clintm
Oct 23 '17 at 22:46












3 Answers
3






active

oldest

votes

















up vote
1
down vote













I don't think this is a bug, unless you see somewhere in the docs that contradicts this behaviour you should probably close the issue you've created.



Tests in go normally live in the package they are testing. You have made a new package with package main at the top (invalid if you also have main elsewhere), and then have included no go source files in that tests/main package (invalid as package has no go source files apart from tests, which the compiler complains about explicitly).



Possible solutions for you (assuming this isn't just a hypothetical question):




  • Move tests for main to test_main.go (this is what readers will
    expect)

  • Add doc.go file to your tests pkg and call it package tests in
    both files


The reason for putting tests in the same package is to ensure they have access to the entire package, if you want to split them to another package you'll find you have to test as an external user of the pkg - this may be painful. Main is also a special case as well as you don't normally import it.






share|improve this answer

















  • 1




    documented here: github.com/golang/go/issues/8279
    – Clintm
    Nov 13 '17 at 16:47










  • That issue is closed with won’t fix
    – Kenny Grant
    Nov 14 '17 at 8:13


















up vote
0
down vote



accepted










Calling it a bug… the build shouldn't fail if the tests compile. Filed here: https://github.com/golang/go/issues/22409



The bug I filed was a duplicate of https://github.com/golang/go/issues/8279 looks like it was broken in 1.3.






share|improve this answer






























    up vote
    -1
    down vote













    First, check your $GOPATH has been set correctly. Learn more at here.



    Then, check if any '_' in your file name. Remove these '_'s and try again.
    ;-)






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46899112%2fgo-build-error-no-non-test-go-files-in-dir%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      1
      down vote













      I don't think this is a bug, unless you see somewhere in the docs that contradicts this behaviour you should probably close the issue you've created.



      Tests in go normally live in the package they are testing. You have made a new package with package main at the top (invalid if you also have main elsewhere), and then have included no go source files in that tests/main package (invalid as package has no go source files apart from tests, which the compiler complains about explicitly).



      Possible solutions for you (assuming this isn't just a hypothetical question):




      • Move tests for main to test_main.go (this is what readers will
        expect)

      • Add doc.go file to your tests pkg and call it package tests in
        both files


      The reason for putting tests in the same package is to ensure they have access to the entire package, if you want to split them to another package you'll find you have to test as an external user of the pkg - this may be painful. Main is also a special case as well as you don't normally import it.






      share|improve this answer

















      • 1




        documented here: github.com/golang/go/issues/8279
        – Clintm
        Nov 13 '17 at 16:47










      • That issue is closed with won’t fix
        – Kenny Grant
        Nov 14 '17 at 8:13















      up vote
      1
      down vote













      I don't think this is a bug, unless you see somewhere in the docs that contradicts this behaviour you should probably close the issue you've created.



      Tests in go normally live in the package they are testing. You have made a new package with package main at the top (invalid if you also have main elsewhere), and then have included no go source files in that tests/main package (invalid as package has no go source files apart from tests, which the compiler complains about explicitly).



      Possible solutions for you (assuming this isn't just a hypothetical question):




      • Move tests for main to test_main.go (this is what readers will
        expect)

      • Add doc.go file to your tests pkg and call it package tests in
        both files


      The reason for putting tests in the same package is to ensure they have access to the entire package, if you want to split them to another package you'll find you have to test as an external user of the pkg - this may be painful. Main is also a special case as well as you don't normally import it.






      share|improve this answer

















      • 1




        documented here: github.com/golang/go/issues/8279
        – Clintm
        Nov 13 '17 at 16:47










      • That issue is closed with won’t fix
        – Kenny Grant
        Nov 14 '17 at 8:13













      up vote
      1
      down vote










      up vote
      1
      down vote









      I don't think this is a bug, unless you see somewhere in the docs that contradicts this behaviour you should probably close the issue you've created.



      Tests in go normally live in the package they are testing. You have made a new package with package main at the top (invalid if you also have main elsewhere), and then have included no go source files in that tests/main package (invalid as package has no go source files apart from tests, which the compiler complains about explicitly).



      Possible solutions for you (assuming this isn't just a hypothetical question):




      • Move tests for main to test_main.go (this is what readers will
        expect)

      • Add doc.go file to your tests pkg and call it package tests in
        both files


      The reason for putting tests in the same package is to ensure they have access to the entire package, if you want to split them to another package you'll find you have to test as an external user of the pkg - this may be painful. Main is also a special case as well as you don't normally import it.






      share|improve this answer












      I don't think this is a bug, unless you see somewhere in the docs that contradicts this behaviour you should probably close the issue you've created.



      Tests in go normally live in the package they are testing. You have made a new package with package main at the top (invalid if you also have main elsewhere), and then have included no go source files in that tests/main package (invalid as package has no go source files apart from tests, which the compiler complains about explicitly).



      Possible solutions for you (assuming this isn't just a hypothetical question):




      • Move tests for main to test_main.go (this is what readers will
        expect)

      • Add doc.go file to your tests pkg and call it package tests in
        both files


      The reason for putting tests in the same package is to ensure they have access to the entire package, if you want to split them to another package you'll find you have to test as an external user of the pkg - this may be painful. Main is also a special case as well as you don't normally import it.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Oct 30 '17 at 22:48









      Kenny Grant

      6,14121633




      6,14121633








      • 1




        documented here: github.com/golang/go/issues/8279
        – Clintm
        Nov 13 '17 at 16:47










      • That issue is closed with won’t fix
        – Kenny Grant
        Nov 14 '17 at 8:13














      • 1




        documented here: github.com/golang/go/issues/8279
        – Clintm
        Nov 13 '17 at 16:47










      • That issue is closed with won’t fix
        – Kenny Grant
        Nov 14 '17 at 8:13








      1




      1




      documented here: github.com/golang/go/issues/8279
      – Clintm
      Nov 13 '17 at 16:47




      documented here: github.com/golang/go/issues/8279
      – Clintm
      Nov 13 '17 at 16:47












      That issue is closed with won’t fix
      – Kenny Grant
      Nov 14 '17 at 8:13




      That issue is closed with won’t fix
      – Kenny Grant
      Nov 14 '17 at 8:13












      up vote
      0
      down vote



      accepted










      Calling it a bug… the build shouldn't fail if the tests compile. Filed here: https://github.com/golang/go/issues/22409



      The bug I filed was a duplicate of https://github.com/golang/go/issues/8279 looks like it was broken in 1.3.






      share|improve this answer



























        up vote
        0
        down vote



        accepted










        Calling it a bug… the build shouldn't fail if the tests compile. Filed here: https://github.com/golang/go/issues/22409



        The bug I filed was a duplicate of https://github.com/golang/go/issues/8279 looks like it was broken in 1.3.






        share|improve this answer

























          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          Calling it a bug… the build shouldn't fail if the tests compile. Filed here: https://github.com/golang/go/issues/22409



          The bug I filed was a duplicate of https://github.com/golang/go/issues/8279 looks like it was broken in 1.3.






          share|improve this answer














          Calling it a bug… the build shouldn't fail if the tests compile. Filed here: https://github.com/golang/go/issues/22409



          The bug I filed was a duplicate of https://github.com/golang/go/issues/8279 looks like it was broken in 1.3.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 '17 at 16:46

























          answered Oct 23 '17 at 23:13









          Clintm

          2,01221933




          2,01221933






















              up vote
              -1
              down vote













              First, check your $GOPATH has been set correctly. Learn more at here.



              Then, check if any '_' in your file name. Remove these '_'s and try again.
              ;-)






              share|improve this answer



























                up vote
                -1
                down vote













                First, check your $GOPATH has been set correctly. Learn more at here.



                Then, check if any '_' in your file name. Remove these '_'s and try again.
                ;-)






                share|improve this answer

























                  up vote
                  -1
                  down vote










                  up vote
                  -1
                  down vote









                  First, check your $GOPATH has been set correctly. Learn more at here.



                  Then, check if any '_' in your file name. Remove these '_'s and try again.
                  ;-)






                  share|improve this answer














                  First, check your $GOPATH has been set correctly. Learn more at here.



                  Then, check if any '_' in your file name. Remove these '_'s and try again.
                  ;-)







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 22 at 14:16

























                  answered Nov 22 at 10:31









                  Morningxxx

                  93




                  93






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46899112%2fgo-build-error-no-non-test-go-files-in-dir%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      What visual should I use to simply compare current year value vs last year in Power BI desktop

                      Alexandru Averescu

                      Trompette piccolo