Bazel & Go Tutorial: Targets with go_library, go_test & go_binary (internal & external deps)

Поделиться
HTML-код
  • Опубликовано: 23 мар 2022
  • In this video we're going to be creating some go targets with Bazel. Bazel is a build tool that is very popular for use in monorepos. We're going to create a go library that doesn't have any external dependencies. We'll write some tests & create targets using go_library and go_test. Then we're going to create a web application & create a go_binary target. The web application will have both third party dependencies & depend on our library in the monorepo.
    Bazel: bazel.build/
    Code: github.com/kriscfoster/multi-...
  • НаукаНаука

Комментарии • 13

  • @ravipandey2839
    @ravipandey2839 Год назад +1

    The entire bazel playlist is really helpful. Using bazel appears to be daunting task at first, but you have broken it down into multiple videos nicely and its easy to follow. Thank you

    • @KrisFoster1
      @KrisFoster1  Год назад

      Thank you very much for the feedback, really glad that you found the videos useful!

  • @sudhanshupatel4069
    @sudhanshupatel4069 11 месяцев назад

    Super helpful content thank you :)

  • @facebren
    @facebren 2 года назад +2

    how does this work using Go modules? Do you still have to bring in all dependencies manually in bazel's BUILD file?

  • @YasserSinjab
    @YasserSinjab 11 месяцев назад

    have you tried to run bazel with gomock before?

  • @_ashout
    @_ashout 2 года назад +1

    What exactly did Gazelle do for you here?

    • @garrettsaxton9184
      @garrettsaxton9184 Год назад +1

      I think gazelle is supposed to create the BUILD.bazel files in each project. They were built manually in this video which may be what you want when building from scratch. ruclips.net/video/mXLrk0ipwz4/видео.html Shows using gazelle if adding Bazel to an existing project. You can probably use gazelle for either type.

    • @OSInetFR
      @OSInetFR Год назад

      @@garrettsaxton9184 That's how I understand it too: unlike other languages which Bazel supports, Go knows quite well how to get the dependencies, even remote, when using the modules mechanisms, so these BUILD.bazel files and the go_repository section in WORKSPACE.bazel look like they can completely be autogenerated from code, and that's what the Gazelle intro describes as being its purpose too. A middleground is using vendoring, which obviates the need to declare all those go_repository entries at the top, and allows referencing them straight from the monorepo top-level vendor directory (with a top-level go.mod).

  • @supervacuum
    @supervacuum Год назад +2

    I struggle to see the benefit of using Bazel, seems overly complicated and surely a Makefile would have yielded the same result?

    • @KrisFoster1
      @KrisFoster1  Год назад +1

      Hi @supervacuum, the benefits of bazel aren't as clear for small projects. In large enterprises with 100s different microservices, a bazel monorepo can be very effective.

    • @supervacuum
      @supervacuum Год назад

      @@KrisFoster1 I see your point - we have used a different approach, each microservice has its own repository and we use GitLab templates to manage all the common aspects of the build. Pros and cons, like any other technology. Thanks for making the video, very informative!

  • @user-nx9mr7xv1b
    @user-nx9mr7xv1b Год назад

    I dont know is the rule is different or what happens, but I can not achieve to execute the build with successful finished. The problem is on goilla/mux inside of BUILD.bazel of the go_web project.