Advertisement
cwchen

[Go] Allocating memory for a struct.

Sep 27th, 2017
1,141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.20 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5. )
  6.  
  7. type Point struct {
  8.     x float64
  9.     y float64
  10. }
  11.  
  12. func main() {
  13.     p := new(Point)
  14.  
  15.     p.x = 3.0
  16.     p.y = 4.0
  17.  
  18.     fmt.Println(fmt.Sprintf("(%.2f, %.2f)", p.x, p.y))
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement