Fireship · @fireship

Go in 100 Seconds

Uploaded October 7, 2021 · Length 2:30

Go in 100 Seconds

Summary

go language basics: installation, syntax, concurrency, and more in 100 seconds.

  • go language
  • programming language
  • statically typed
  • compiled language
  • concurrency

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    go a statically typed compiled language

  2. 0:03

    often described as C for the 21st

  3. 0:05

    century it's a popular choice for high

  4. 0:07

    performance serers side applications and

  5. 0:09

    is the language that built tools like

  6. 0:11

    Docker cockroach DB and dgraph it was

  7. 0:14

    created at Google in 2007 by Legends who

  8. 0:17

    really know their stuff like Ken

  9. 0:19

    Thompson the inventor of the B and C

  10. 0:21

    programming languages version 1.0 was

  11. 0:23

    released as open-source software in 2012

  12. 0:26

    it was designed for Simplicity and

  13. 0:28

    efficiency and that's why we call it go

  14. 0:30

    and not go Lang the source code is

  15. 0:32

    compiled down to machine code which

  16. 0:34

    means it generally outperforms

  17. 0:35

    interpreted languages but it's famous

  18. 0:37

    for its extremely fast compile times

  19. 0:39

    made possible by Innovations to

  20. 0:41

    dependency analysis and even though it's

  21. 0:43

    a statically typed language it performs

  22. 0:45

    type inference to deliver a syntax that

  23. 0:47

    is very concise and practical it also

  24. 0:49

    has a package and module system making

  25. 0:51

    it easy to Import and Export code

  26. 0:54

    between projects to get started install

  27. 0:56

    go and then open an empty directory on

  28. 0:58

    your system create a file ending and.go

  29. 1:01

    then add package main at the top to

  30. 1:03

    create a standalone executable then

  31. 1:05

    declare a main function which is where

  32. 1:07

    your program will start executing go has

  33. 1:10

    a standard library of core packages to

  34. 1:12

    handle common requirements like math

  35. 1:14

    networking or formatted IO by importing

  36. 1:17

    fmt we can print a line to the standard

  37. 1:19

    output then run the go build command and

  38. 1:22

    it quickly compiles the source code and

  39. 1:24

    dependencies into an executable binary

  40. 1:26

    when it comes to dependencies we can

  41. 1:28

    also link to remote packages on GitHub

  42. 1:30

    run go mod a knit from the command line

  43. 1:32

    and that creates a go module file that

  44. 1:34

    enables dependency tracking

  45. 1:35

    syntactically go is like a concise

  46. 1:37

    version of C or C++ declare a variable

  47. 1:40

    with the VAR keyword followed by its

  48. 1:42

    name and type and initialize it with a

  49. 1:44

    value or you might use the short

  50. 1:46

    assignment syntax to replace VAR and let

  51. 1:48

    go automatically infer the type and you

  52. 1:51

    can Define multiple variables from a

  53. 1:52

    single line go has all the other

  54. 1:54

    features you would expect in a

  55. 1:55

    programming language like arrays Maps

  56. 1:57

    loops and control flow but also allows

  57. 1:59

    you to store the memory address of a