FAQ
If the type is not exported, you cannot create an instance by just doing:

    a := &foo.bar{123}

To create an instance, the package "foo" FORCES you to use a function
(which acts like a constructor) :

    a := foo.Newbar(123)

It may be useful if the type "bar" is a complex type that needs a lot of
initializations.
This way, you are sure that the user cannot create one by himself, and must
use your constructor.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 8 of 16 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 14, '15 at 10:46a
activeJan 17, '15 at 3:45a
posts16
users7
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase