Go Built-In Function new

From NovaOrdis Knowledge Base
Revision as of 01:28, 30 March 2016 by Ovidiu (talk | contribs)
Jump to navigation Jump to search

External

Internal

Overview

The new() built-in function takes a type as argument, allocates memory of the given type and returns a pointer to it.

var ptr *some_type
ptr = new(some_type)

We don't have to worry about de-allocating memory allocated with new(). It is automatically garbage collected.