Golang / GoLang Basics Interview Questions
What are the fundamental data types in Go?
Go has a concise but complete set of built-in primitive types. Choosing the right type — especially between int and sized integers, and between float32 and float64 — matters for correctness and interoperability.
| Category | Types | Common default |
|---|---|---|
| Signed integers | int8, int16, int32, int64, int | int (platform width: 64-bit on 64-bit OS) |
| Unsigned integers | uint8, uint16, uint32, uint64, uint | uint8 alias = byte |
| Floating point | float32, float64 | float64 (more precise; the default) |
| Boolean | bool | false |
| String | string | "" (immutable UTF-8 bytes) |
| Rune | rune (= int32) | represents a Unicode code point |
var i int = 42
var f float64 = 3.14159
var b byte = 255 // alias for uint8
var r rune = '⚡' // alias for int32 — Unicode code point
var str string = "Hello, 世界"
// Type conversions are ALWAYS explicit — no implicit casting
var x int = 100
var y float64 = float64(x) // must be explicit
var z int = int(y) // truncates decimal part
// String byte count vs character count (UTF-8)
fmt.Println(len(str)) // 13 bytes
fmt.Println(len([]rune(str))) // 9 runes/characters
// Constants are untyped by default — flexible in expressions
const Pi = 3.14159
const MaxItems = 1000
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
