Null container in go

Home Forums Go Programming Null container in go

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5447 Reply
    Humble
    Keymaster

    Lets start with null

    We have seen many times in go packages that, variables are initialized as “_”. That basically means:

    Underscore is a special character in Go which acts as a null container. After importing or after assigning a variable in Go, if we are not using it, go compiler will throw an error. To avoid that, we are storing reference of that package/variable into _, and Go compiler will simply ignore it.

    Aliasing a package with an underscore which seems to do nothing is quite useful sometimes when you want to initialize a package but not use it.

    #5479 Reply
    Humble
    Keymaster
    This reply has been marked as private.
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Null container in go
Your information: