Home > other >  The go if there is any need to increase the get object, set method
The go if there is any need to increase the get object, set method

Time:09-23

Newbie on the road, I from the C/C + + to Java development, is now turning to Go, because the Java development habit, usually write get for object, set method, following the basic grammar when I learned the Go read some open source products, basic is very rare to see someone as struct objects. Write the get to set method, want to consult everybody here, Go developing whether there is a need to increase the get and set methods, if you have, what circumstance needs, is another question about package path
` ` `
- a
-- -- -- -- --
b-- -- -- -- -- -- -- bb. Go
-- -- -- -- --
c-- -- -- -- -- -- - cc. Go
- aa. Go
` ` `
A path with a aa. Go file, at the same time a path with b, c two subpaths, they were found in bb. Go and cc. Go file
Like this package path whether to allow? If allowed, aa. Go in how to use the package b and c, the contents of the package?
Thank you very much for answer friend,

CodePudding user response:

1. People think casual, it is recommended to use more the case go to control the
2. Can it as it is, through the full path or a relative path to access, such as a/a/b/bb or./b/bb - if bb. Go package is bb,

CodePudding user response:

Member attribute to best like c # compiler to support or optimization, otherwise my to define the get set method and so on are all junk code, the development and execution efficiency is low, golang function call means that the parameters and return values of a copy,

CodePudding user response:

Thank you very much!

CodePudding user response:

Thank you very much! Excuse me if you have any value is whether the pointer passed a copy of the problem, go have a framework like spring?

CodePudding user response:

The pointer itself is also variable, parameter is a copy of the pointer itself, understand the speakers of other languages in shallow copy

CodePudding user response:

Basic can understand as the pointer passed as shallow copy, but the difference and C pointer passed to a certain extent,

See also:
Reference
even if Go look a bit like C, the compiler works is different also, C analogy does not always work together and Go, and Go in value transfer may be smaller than a pointer passed overhead, this happens because the Go use escape analysis to determine whether variables can be assigned to safely function on the stack frame, which may much smaller than variable overhead is allocated on the heap, passing by value analysis to simplify the escape in the Go, and provide opportunities for the better distribution of variables,

Author: ginger, small size
Link: https://www.jianshu.com/p/759b28a2552c
Source: Jane books
Copyright owned by the author, commercial reproduced please contact the author for authorization, non-commercial reprint please indicate the source,
  • Related