Where to put constants shared by multiple files with package scope? [closed] - go

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I have a Go package that declares and uses some constants in file1.go. Now I add a new file to the package, file2.go, which refers to constants in file1.go.
Would you move the shared constants into a new file, like consts.go, since they don't "belong" to one file or the other? Or do you leave them in file1.go and assume that someone looking at file2.go can use their IDE or editor or grep to locate the shared constants?

Using const.go file is an idiomatic way, see Go standard library.
For example see: math/const.go

Related

Why isn't "close" a reserved keyword? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
close() seems to be a reserved keyword for channels. Seems a bit strong to make it a built-in, when it could just be a method on a channel, no? Like when creating and closing a file?
I guess the same could be asked for len()?
close is a function that takes a channel as a parameter. Just like new and make, they are functions, and you can name local variables or functions like them.
Keywords are language constructs like struct, type, if, else ...

What are the new JVM arguments introduces in Java8? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Very basic but can any one tell me what are the new JVM arguments introduces in Java8?
I am not able to find any concrete list over net.
I know about a few of them only (that I got to use), like:
-parameters (for named parameters)
Since the addition of meta-space, these were added (used only a few of them)
InitialBootClassLoaderMetaspaceSize
MaxMetaspaceExpansion
MaxMetaspaceFreeRatio
MaxMetaspaceSize
MetaspaceSize
MinMetaspaceExpansion
MinMetaspaceFreeRatio
UseLargePagesInMetaspace
And one about lambda usage:
-Djdk.internal.lambda.dumpProxyClasses = /Some/Path
I only vaguely know about these two:
MinHeapFreeRatio
MaxHeapFreeRatio
I am absolutely sure there are many more...

What are the advantages/disadvantages of using "SHC" to convert script to binary file [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
What are the advantages / disadvantages of converting a shell script into a binary file?
I have done that and when I run the binary file on another linux it doesn't run.
it gives this error
version 'GLIBC_2.14' not found (required by ./test.sh.x)
on another server it gives this ./test.sh.x: Invalid argument.
The script only does a echo "hello"
The only 'advantage' is obfuscation, the disadvantages numerous as the examples in your question show.
If you're using it to hide secrets (passwords) they are easy to extract anyway.

Accessing Module Methods Best Practice ( '.' vs '::' ) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Is it best practice to access module methods with a dot (.) or the scope resolution operator (::)?
I know both work and I understand the purpose of ::, I would just like to know which to favour when accessing module methods and why.
Note: There is a related question here which goes into this topic, but not into which is better form.
Both work but the Calling Methods docs suggest that you should use :: for namespaces:
You may also use :: to designate a receiver, but this is
rarely used due to the potential for confusion with ::
for namespaces.

Following programming styles -- update poor adherence? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have a project I am working on that is written in Python. The variable/class/function/everything names do not adhere to the Python style guide.
example: a variable might be called myRandomVariable instead of the proper: my_random_variable
My question is, is it worth combing through all the code (around 10,000 lines) to fix all the naming convention problems or should I just say, 'the heck with it -- it works'?
Thanks
Edited to give example
Just because there is a Python style guide, it does not mean that all Python code should adhere to it. The most important thing to consider in a code base is that it's consistent with itself, at LEAST on a per-file basis, preferably across the project!
I would vote for your second option. They are just styles. Everyone will have their own style. You don't need to be in compilance with defined styles to say your product is great.

Resources