Debug School

Rajesh Kumar
Rajesh Kumar

Posted on

Day 1 - Golang - Aug 2026

How to install Go in Ubuntu
URL - Guide

Lets Run Fundamental Code in Go
https://www.devopsschool.com/tutorials/go-tutorials-foundation-level/

** Advance Go Array - Slice - Map - Struct **
https://www.devopsschool.com/tutorials/go-tutorials-arrays-slices-maps-and-structs/

Go Tutorials: Arrays, Slices, Maps, and Structs
https://www.devopsschool.com/tutorials/go-tutorials-arrays-slices-maps-and-structs/

Go Tutorial: Go Functions and Methods
https://www.devopsschool.com/tutorials/go-tutorial-go-functions-and-methods/

Go Tutorial: Go Interfaces
https://www.devopsschool.com/tutorials/go-tutorial-go-interfaces/

Go concurrency
https://www.devopsschool.com/tutorials/go-tutorials-go-concurrency-beginner-tutorial/

Top comments (3)

Collapse
 
akash_singh_9d8e2205dc9ac profile image
Akash Singh • Edited
package main

import "fmt"

func main() {
    var  message float32 = 1.3

    // p stores the address of message.
    p := &message

    fmt.Println("original:", message)
    fmt.Println("through pointer:", *p)
    fmt.Println(p)
    // Dereferencing lets us update the original value.
    *p = 234234234.5324234234
    fmt.Println(p)
    fmt.Println("updated:", message)
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
rajesh_kumar profile image
Rajesh Kumar

float32 only has about 6–7 decimal digits of precision.

Your number:

234234234.5324234234

has far more precision than float32 can store.

Therefore Go will store an approximation, likely something around:

234234240

or display it in scientific notation such as:

2.3423424e+08

This is not a pointer problem. It is a float32 precision limitation.

Collapse
 
srushti profile image
Srushti D A

package main

import "fmt"

func main() {
// Start empty, with room for three strings before growth is needed.
names := make([]string, 0, 3)

names = append(names, "Asha")
names = append(names, "Ben", "Chen")
names = append(names, "sru")
fmt.Println("names:", names)
fmt.Println("length:", len(names))
fmt.Println("capacity:", cap(names))

// Slice expressions can create a view over part of a slice.
firstTwo := names[:2]
fmt.Println("first two:", firstTwo)
Enter fullscreen mode Exit fullscreen mode

}

O/P: > go run hello.go
names: [Asha Ben Chen sru]
length: 4
capacity: 6
first two: [Asha Ben]

what is the logic behind the capacity here?