“Deklarieren Sie variabler Golang” Code-Antworten

Variablen in Go

package main

import "fmt"

func variables() {
	//constant
	const APP_NAME string = "NEW APP"

	// first define the name then the type
	var age int32 = 10

	// group of variables
	var (
		name  string = "Himanshu"
		class int32  = 19
	)

	// over write a variable
	name = "Himanshu Jangid"

	// declare multiple variables
	x, y := 10, 20

	println("Multiple Variables", name, class, x)

	// pointers
	var p *int = &x
	println(x, p)

	println("Before Swap", x, y)
	swap(&x, &y)
	println("After Swap", x, y)

	// we can also print without fmt
	println(APP_NAME, age)

	var my_name = "Some Name"
	println("We Have This many chars: ", len(my_name))

	fmt.Printf("typeof my name is : %T \n", my_name)
}

// swap values via pointers
func swap(x *int, y *int) {
	*x, *y = *y, *x
}
Himanshu Jangid

Variablen in Golang

package main

import "fmt"

func main() {
    number := 100
    decimal := 98.6
    phrase := "Hello World"
    result := true
}
Old Pizza

Deklarieren Sie variabler Golang

//All 3 ways to declare a variable in Go
var x int
var x int = 10 //declare and initialize variable
x:= 10 //declare and initialize variable
Armandres

var () golang

package main

import "fmt"

var (
	product  = "Mobile"
	quantity = 50
	price    = 50.50
	inStock  = true
)

func main() {
	fmt.Println(quantity)
	fmt.Println(price)
	fmt.Println(product)
	fmt.Println(inStock)
}
Subham Mallick

Variablen in Golang

var msg string
msg = "Hello"
Harendra

Ähnliche Antworten wie “Deklarieren Sie variabler Golang”

Fragen ähnlich wie “Deklarieren Sie variabler Golang”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen