9951 explained code solutions for 126 technologies


golangHow to format float without decimals


package main
import "fmt"

func main() {
  res := fmt.Sprintf("Float: %.0f", 123.3)
  fmt.Println(res)
}ctrl + c
package main

default package declaration

import "fmt"

loads fmt package to operate on strings (and print them)

fmt.Sprintf(

formats given string based on a given template and return result

%.0f

removes decimals from given float number

123.3

sample float number to format

fmt.Println

prints specified string