The TRUTH About Golang Backend Frameworks

00:06:30
https://www.youtube.com/watch?v=JECZTdEJnOI

Resumen

TLDRThe video provides an overview of different frameworks available for building Go backends, such as Gin, Chi, Fiber, and Echo. The speaker points out that while there are many options, most frameworks are essentially wrappers around Go's standard library. They emphasize the importance of starting with the standard library and understanding its capabilities before considering external libraries. By separating Go development from JavaScript frameworks' overwhelming options, the speaker encourages new Go developers to rely on the standard library to build APIs effectively and efficiently.

Para llevar

  • ✨ There are many Go frameworks, but no one 'right' choice.
  • 🔧 Most frameworks are wrappers around Go’s standard library.
  • 📚 Start with the standard library before using frameworks.
  • 🔍 Explore standard library features to build comprehensive APIs.
  • 🙅‍♂️ Don’t get caught in the JavaScript problem of too many choices.
  • ⚡ HTTP Router is a simple alternative closest to the standard library.
  • 💡 Use the standard library first to improve your understanding of Go.
  • 📧 Specialized libraries are available for tasks like emailing and JWT handling.
  • 🧩 Try removing frameworks and using only the standard library in your applications.
  • 📝 Challenge yourself to replicate framework functionalities with the standard library.

Cronología

  • 00:00:00 - 00:06:30

    The video addresses the confusion many Go developers face when selecting frameworks for building Go backends for APIs. It highlights the concept of the 'JavaScript problem', where an abundance of options can create uncertainty. The speaker reviews multiple Go frameworks such as Chi, Gin, Fiber, and Echo, noting that they essentially serve as wrappers around Go's standard library, performing similar functions. The core takeaway emphasizes that Go's standard library is robust enough for various needs, urging developers to focus on it first before turning to external frameworks. Additionally, HTTP Router by Julian Schmidt is recommended for being close to the standard library's functionality. The speaker encourages not to over-rely on frameworks and challenges viewers to replicate framework functionalities using only the standard library.

Mapa mental

Vídeo de preguntas y respuestas

  • What is the best Go framework for building APIs?

    There is no single 'best' framework; options like Gin, Chi, Fiber, and Echo offer similar abilities.

  • Should I use a framework or the standard library in Go?

    It's recommended to start with the standard library unless you have a specific use case that requires a framework.

  • What is the JavaScript problem?

    The JavaScript problem refers to the overwhelming number of tools and libraries available, making it difficult to choose the right one.

  • What is HTTP router in Go?

    HTTP router is a minimal routing library that closely resembles the Go standard library, providing essential routing capabilities.

  • Why use the Go standard library?

    The standard library is well-defined and can handle most needs without the complexity of third-party frameworks.

  • What is the difference between Gin and Echo?

    Both Gin and Echo provide routing capabilities but utilize different implementations and features.

  • Can I build a Go API without a framework?

    Yes, the Go standard library is sufficient for building APIs without needing additional frameworks.

  • What are some other Go libraries to consider?

    For specific tasks like sending emails or handling JWTs, there are specialized libraries available in the Go ecosystem.

  • What should I do if I'm new to Go?

    Experiment with the standard library first before importing external libraries or frameworks.

  • What did the speaker challenge viewers to do?

    The speaker challenges viewers to replicate their framework-based applications using only the standard library.

Ver más resúmenes de vídeos

Obtén acceso instantáneo a resúmenes gratuitos de vídeos de YouTube gracias a la IA.
Subtítulos
en
Desplazamiento automático:
  • 00:00:00
    if you are coding in go you have
  • 00:00:02
    probably asked yourself what go
  • 00:00:05
    framework should I use now I want to be
  • 00:00:07
    specific and focus on Frameworks that
  • 00:00:09
    people would typically use when they're
  • 00:00:11
    building a go backend for their API and
  • 00:00:14
    not so much Frameworks they would use
  • 00:00:15
    for creating something like acli which
  • 00:00:17
    if you haven't heard already Cobra and
  • 00:00:19
    charm are great options so go use them
  • 00:00:22
    it doesn't take a whole lot of effort to
  • 00:00:23
    do one quick Google search on what go
  • 00:00:26
    framework to use to see a whole bunch of
  • 00:00:28
    lists pop up and then you get yourself
  • 00:00:30
    into what I like to call the JavaScript
  • 00:00:33
    problem the JavaScript problem is when
  • 00:00:36
    there's too many options of what tool
  • 00:00:39
    Library framework to use without
  • 00:00:41
    actually knowing which one you truly
  • 00:00:43
    need and want for your applications in
  • 00:00:46
    JavaScript is react view svelte solid
  • 00:00:50
    Astro next I mean it's JavaScript the
  • 00:00:53
    ecosystem is evolving and changing every
  • 00:00:55
    single day but in go I mean there's also
  • 00:00:58
    a lot of options there's gin there's Qi
  • 00:01:01
    there's fiber there's Echo there's
  • 00:01:03
    Vulpix that's a Pokemon I
  • 00:01:06
    try to trick you
  • 00:01:08
    the very best which framework is right
  • 00:01:11
    for them well that's the actual thing
  • 00:01:13
    there is no right framework in go so you
  • 00:01:17
    can see here I'm on go Chi and if I just
  • 00:01:20
    read the first bit of the readme QI is a
  • 00:01:22
    lightweight idiomatic and composable
  • 00:01:25
    router for building go HTTP Services if
  • 00:01:30
    I flip to go Jin Jin is a web framework
  • 00:01:33
    writ and go it features a martini lick
  • 00:01:37
    API with performance that is up to 40
  • 00:01:39
    times faster thanks to http router if
  • 00:01:43
    you check out go fiber fiber is an
  • 00:01:46
    Express inspired web framework built on
  • 00:01:49
    top of fast HTTP the fastest HTTP engine
  • 00:01:53
    for go and if we check go Echo we can do
  • 00:01:55
    some of the featured overviews optimized
  • 00:01:57
    HP router with smartly prioritized
  • 00:01:59
    routes build robust and scalable restful
  • 00:02:02
    apis have you noticed a pattern you see
  • 00:02:05
    a lot of these libraries in go these
  • 00:02:07
    Frameworks are essentially doing the
  • 00:02:10
    same thing they are just rappers on top
  • 00:02:13
    of the standard library that go offers
  • 00:02:16
    and this isn't necessary that's a sad
  • 00:02:18
    thing and I'm not saying all of these
  • 00:02:19
    are the exact same but when you are
  • 00:02:22
    focusing on just creating routes or
  • 00:02:24
    middleware or anything like that you can
  • 00:02:26
    pick any of them here we're back on go
  • 00:02:28
    Chi and you can see this example as easy
  • 00:02:30
    as you have your import so there's Qi
  • 00:02:32
    there's a standard HTTP library and
  • 00:02:34
    they're in your function main you create
  • 00:02:36
    your new router using Chi Library you
  • 00:02:38
    create the middleware and you're
  • 00:02:40
    designing a route here this get route
  • 00:02:42
    with a response that just says welcome
  • 00:02:44
    looks super simple wow Qi is great all
  • 00:02:47
    right let's flip on to Jen for a second
  • 00:02:49
    gin you have your import net HTTP and
  • 00:02:52
    Jin okay awesome so you create gin dot
  • 00:02:55
    default and oh oh you define your route
  • 00:02:58
    that has a response okay cool this is
  • 00:03:01
    great this is awesome how about we check
  • 00:03:03
    out fiber for a second you have your
  • 00:03:04
    import fiber and oh oh app fiber.new and
  • 00:03:08
    you define
  • 00:03:10
    this looks almost exactly the same you
  • 00:03:12
    have to get route that just says hello
  • 00:03:14
    world okay well how about we check out
  • 00:03:15
    Echo for real quickly just you know just
  • 00:03:18
    to check out how different can it be and
  • 00:03:19
    oh you create your new Echo instance
  • 00:03:22
    okay middleware or all right and you you
  • 00:03:25
    get route
  • 00:03:27
    with a response that says hello world
  • 00:03:29
    you can see that all of them followed
  • 00:03:32
    the same pattern and yes Jin and Chi may
  • 00:03:35
    have things that provide more use case
  • 00:03:38
    in a fully fleshed out library and
  • 00:03:41
    framework to use but at the end of the
  • 00:03:43
    day you create the instant you define
  • 00:03:46
    your get or post route and you pass it a
  • 00:03:48
    function or literally a Json payload and
  • 00:03:50
    it just does what you tell it to the
  • 00:03:52
    Handler respond to the route how you
  • 00:03:55
    define it and it looks the exact same
  • 00:03:57
    way for every single one and just to
  • 00:04:00
    Showcase another example one that I
  • 00:04:02
    personally recommend is HTTP router by
  • 00:04:04
    Julian Schmidt because this is the
  • 00:04:08
    closest to the standard library that you
  • 00:04:09
    can get between all the examples I
  • 00:04:11
    previously showed you can see here
  • 00:04:13
    Define two handlers index and hello you
  • 00:04:15
    define your routes by instantiating HTTP
  • 00:04:17
    router from the library you pull in and
  • 00:04:19
    then you have a two dot get map method
  • 00:04:22
    on these two routes declared and they
  • 00:04:23
    will pass the function of the Handler
  • 00:04:25
    and so what I really want to kind of
  • 00:04:26
    convey and what I always talk about when
  • 00:04:29
    I explain go to someone is that you have
  • 00:04:31
    to separate your thinking of go from
  • 00:04:33
    JavaScript if you're coming from that
  • 00:04:34
    world or any other world because go you
  • 00:04:37
    can truly do everything with the
  • 00:04:40
    standard Library go isn't that program
  • 00:04:42
    language where you should be picky and
  • 00:04:44
    really pulling resources or deciding
  • 00:04:47
    which framework is right for you of
  • 00:04:49
    course you can use particular use cases
  • 00:04:51
    that you can read about and really
  • 00:04:52
    discover that huh this really solved the
  • 00:04:54
    problem I have I'm going to use and
  • 00:04:56
    that's pretty perfectly fine but if
  • 00:04:58
    you're spending time spinning your
  • 00:04:59
    wheels on deciding from all the frames
  • 00:05:02
    that you see from a best framework to
  • 00:05:04
    use in 2023 list you're wasting your
  • 00:05:06
    time what I recommend to everyone who's
  • 00:05:08
    starting with go is essentially try to
  • 00:05:10
    do things using just the standard
  • 00:05:12
    Library don't start importing modules or
  • 00:05:16
    Frameworks if you don't need them
  • 00:05:17
    they're all the same but why am I
  • 00:05:19
    recommending HTTP router milk didn't you
  • 00:05:21
    just say try to make it yourself and
  • 00:05:23
    that's a valid point but like I said
  • 00:05:24
    earlier HTTP router is the closest one
  • 00:05:27
    to the standard library and that is why
  • 00:05:30
    I personally like it you don't need to
  • 00:05:33
    bring anything new it's simply just a
  • 00:05:36
    router that gives you everything you
  • 00:05:37
    need to fully pass in any Handler you
  • 00:05:40
    decide to create and there's other
  • 00:05:42
    libraries and Frameworks they can use in
  • 00:05:43
    the go ecosystem richest people always
  • 00:05:46
    developing new things to use if you want
  • 00:05:48
    to use something for sending emails or
  • 00:05:50
    specifically handling you know crypto
  • 00:05:52
    hashes or jaw tokens or anything like
  • 00:05:55
    that there's something that there for
  • 00:05:57
    you but use a standard Library explore
  • 00:05:59
    the standard Library first you'll be
  • 00:06:02
    surprised on how well and defined those
  • 00:06:04
    things come stock in the go ecosystem so
  • 00:06:07
    with that guys I gotta leave you with
  • 00:06:09
    two things out of all of the Frameworks
  • 00:06:10
    I just decided and listed which one have
  • 00:06:12
    you used for your go application and if
  • 00:06:14
    you if you used one I challenge you to
  • 00:06:16
    use the standard Library remove that
  • 00:06:19
    framework from your app and just try
  • 00:06:21
    replicating it with the standard library
  • 00:06:23
    and let me know if you're successful or
  • 00:06:25
    not and two
  • 00:06:28
    you gotta power it
Etiquetas
  • Go
  • Frameworks
  • Backend
  • API
  • Gin
  • Chi
  • Fiber
  • Echo
  • Standard Library
  • HTTP Router