Skip to content

Instantly share code, notes, and snippets.

@pedrobertao
Last active August 27, 2023 12:16
Show Gist options
  • Save pedrobertao/ecb14746900c8730e6c066ca2cf2ebeb to your computer and use it in GitHub Desktop.
Save pedrobertao/ecb14746900c8730e6c066ca2cf2ebeb to your computer and use it in GitHub Desktop.
Min/Max Golang 1.21
package main
import "fmt"
func main() {
minInt := min(3, 2, 1, 4)
minFloat := min(4.0, 2.0, 3.0, 1.0)
minString := min("ab", "a", "abcd", "abc")
fmt.Println("Min Integer:", minInt)
fmt.Println("Min Float:", minFloat)
fmt.Println("Min String:", minString)
fmt.Println("==================")
maxInt := max(4, 2, 3, 1)
maxFloat := max(1.0, 4.0, 2.0, 3.0)
maxString := max("a", "ab", "abc", "abcd")
fmt.Println("Max Integer:", maxInt)
fmt.Println("Max Float:", maxFloat)
fmt.Println("Max String:", maxString)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment