Stop using `go run main.go`

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ก.ย. 2024
  • Why is `go run main.go` a bad idea? Let me explain!

ความคิดเห็น • 19

  • @ohLyln
    @ohLyln 10 หลายเดือนก่อน +7

    This was super useful. I know this probably is not best practice but I put everything in sub-packages besides my main.go so I have never experienced this case, but I'm sure this is going to save me from a future headache where I don't get why my project isn't running haha, thanks!

    • @boldlygo
      @boldlygo  10 หลายเดือนก่อน +2

      Keeping things organized in packages is actually a really good idea.

  • @higiniofuentes2551
    @higiniofuentes2551 หลายเดือนก่อน +1

    Thank you for this very useful video!

  • @ihatesun
    @ihatesun 10 หลายเดือนก่อน +1

    Great vid. I tend to skip a fair amount of important details and this one for me was like "Whoa"

  • @mgan59
    @mgan59 10 หลายเดือนก่อน +1

    I've been relearning Go, helpful insight as I'm familiarizing myself with best practices around packaging / modules

  • @GV14982
    @GV14982 10 หลายเดือนก่อน +1

    This was really informative and concise! Thanks :)

  • @Christian-of1tz
    @Christian-of1tz 10 หลายเดือนก่อน +1

    It also does not work with workspaces. There are also cases where you have to change into the module folder to work correctly. (Not sure which, I forgot but I am always annoyed by this.)

  • @ttuurrttlle
    @ttuurrttlle 10 หลายเดือนก่อน +1

    I've just started with go like last week, haven't written much. But I've been tired of writing go run main.go. or tabing up in the terminal for that command. I just wanna configure VS Code to run the active file window when I press f5. I just gotta figure out how those VS Code configuations things work

  • @Alx-st7yj
    @Alx-st7yj 10 หลายเดือนก่อน

    Hi, can you review book "go cookbook" by Sau Sheong Chang?!

  • @bobbobson6290
    @bobbobson6290 10 หลายเดือนก่อน

    I do what I want.
    You're not my mom!

    • @boldlygo
      @boldlygo  10 หลายเดือนก่อน +1

      No dessert for you! 😂

  • @cmelgarejo
    @cmelgarejo 10 หลายเดือนก่อน +5

    You already did alot of effort explaining what are the no-effort videos, next just go on with the content and the awkwardness 😂

    • @boldlygo
      @boldlygo  10 หลายเดือนก่อน +2

      Fair point. But not everyone watches every video. So I like a brief explainer for anyone who jumps into the middle of the series.

    • @cmelgarejo
      @cmelgarejo 10 หลายเดือนก่อน +2

      @@boldlygo fair, but just indulge us who follow your antics already heheh

  • @polymath-403
    @polymath-403 2 หลายเดือนก่อน

  • @jeffreysmith9837
    @jeffreysmith9837 3 หลายเดือนก่อน

    I was expecting something about how go run . breaks if you have test files in the package

    • @boldlygo
      @boldlygo  3 หลายเดือนก่อน

      Can you elaborate on what you mean?

    • @jeffreysmith9837
      @jeffreysmith9837 3 หลายเดือนก่อน +1

      @@boldlygo
      Sorry my mistake.
      It's `go run ./*` that breaks if there are non-go files or *_test.go files.
      But I forgot why I was using * in the first place. I probably shouldn't do that.
      `go run .` without the asterisk works fine

    • @boldlygo
      @boldlygo  3 หลายเดือนก่อน +1

      Ah yes. * in a go run path can cause all kinds of chaos!