Answers for "how to allocate memory in go"

Go
0

how to manually allocate memory in golang

package main

import "fmt"

func main(){

   ptr := new(int)
   *ptr = 100

   fmt.Println("*ptr = ", *ptr)

   slice := make([]int, 10)    // slice with len(slice) == cap(slice) == 10

   for i:=0; i<len(slice); i++{
      fmt.Println(slice[i])
   }
}
Posted by: Guest on March-12-2020

Code answers related to "how to allocate memory in go"

Browse Popular Code Answers by Language