FAQ
Hi

I'm new to Go and would like to start with a small project to learn it.
From other programming languages I know namespaces or modules for grouping
some functionality.

For example:
For a small blog in C# I would create a namespace "Managers" and inside the
different classes like "PostManager", "CommentManager" with the different
methods for the DB access.

My approach in Go would be to have the structs "post", "comment" and so on
with functions like "fill", which would be defined once for every struct as
a simple method, not connected to the struct, to be able to return that
struct.
This would get conflicts...

Is there something similar in Go or do I need to create multiple packages
for my project?

Search Discussions

  • Ian Lance Taylor at Sep 10, 2012 at 10:27 pm

    On Mon, Sep 10, 2012 at 2:34 PM, Curdin Caspar wrote:
    I'm new to Go and would like to start with a small project to learn it.
    From other programming languages I know namespaces or modules for grouping
    some functionality.

    For example:
    For a small blog in C# I would create a namespace "Managers" and inside the
    different classes like "PostManager", "CommentManager" with the different
    methods for the DB access.

    My approach in Go would be to have the structs "post", "comment" and so on
    with functions like "fill", which would be defined once for every struct as
    a simple method, not connected to the struct, to be able to return that
    struct.
    This would get conflicts...

    Is there something similar in Go or do I need to create multiple packages
    for my project?
    In Go, use packages when you want different name spaces.

    Ian

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 10, '12 at 10:03p
activeSep 10, '12 at 10:27p
posts2
users2
websitegolang.org

2 users in discussion

Curdin Caspar: 1 post Ian Lance Taylor: 1 post

People

Translate

site design / logo © 2022 Grokbase