golang - 2

technonotes

technonotes-hacker

Posted on March 3, 2024

golang - 2

TYPES

Image description

  • Variable --> to store value.

Image description

  • strongly typed language.

Image description

INT

  • These are used to declare INTEGER values.

  • upending two string in INT

Image description

Image description

  • Testing with Negative values

Image description

FLOAT

Image description

Image description

Image description

STRING

Image description

Image description

COMPLEX

  • It provides the real and imaginary value.
package main
import (
    "fmt"
)
func main() {
    var i complex64 = 2
    fmt.Println(i)
}
Enter fullscreen mode Exit fullscreen mode

Image description

BOOLEAN

  • Default value is FALSE.
package main
import (
    "fmt"
)
func main() {
    var i bool
    fmt.Println(i)
}
Enter fullscreen mode Exit fullscreen mode

Image description

  • Where it's used ? We can test with Condition.
package main
import (
    "fmt"
)
func main() {
    var i bool = 4 > 2
    fmt.Println(i)
}
Enter fullscreen mode Exit fullscreen mode

Image description

CONSTANT

  • You can define , and it can't be changed.

TYPE CONVERSION

  • It can convert from one type to another type.

Notes

  1. 1 byte = 8 bit ( high bit will be allocated to --> signature , 2 power 7 = 0 to 127 --> it accepts , range = -127 to +127 ) Eg., var i int8
  2. uint --> Reservation will be ignored. So 0 to 128 , also negative value will not be assigned. --> unsigned Integer
  3. 1 byte = uint8
  4. rune = int32
  5. Typed system is important because of the allocation of the memory.
  6. Eg., Bank Balance can be negative, if you take loan && The element with the lowest freezing point is helium, which freezes at a temperature of approximately -272.2 degrees.
  7. The Two’s Complement has unaltered positive numbers just like Sign-and-Magnitude and One’s Complement methods. The negative number is obtained by first determining the one’s complement of the relevant positive number and then adding “1” to it. The range of numbers is -128 to 0 to +127 and includes only one zero in the range.

Reference & Important Sites

https://go.dev/tour/basics/1
https://forums.tamillinuxcommunity.org/t/lets-learn-golang/1725/2
https://gitlab.com/mohan43u/letslearngolangdocs/-/blob/master/week0.org
https://go.dev/tour/list

💖 💪 🙅 🚩
technonotes
technonotes-hacker

Posted on March 3, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related