Hello. I’m new to go and somewhat new to programming in general. Please forgive me if any of my nomenclature is off here. I might use a word or two incorrectly.
I’m using visual studio code to get helpful recommendations for autocomplete but I’m having a hard time understanding the type suggestions and using the documentation to figure out what data structures these methods actually want.
This is a problem more generally but I do have a specific example.
First example is pretty succinct:
It shows func OpenFile(name string, flag int, perm FileMode) (*File, error) which I take to mean that OpenFile is a method of the OS package that takes three parameters and returns two values.
The first parameter takes a string that will get assigned to a variable named “name” in the local scope of the method, the second parameter takes an int that will get assigned to a variable named “flag” in the local scope of the method, and the third parameter takes a “FileMode” data type that will get assigned to a variable named “perm” in the local scope of the method.
So first there is the question of whether I am understanding all of that correctly. If I am then I have the question of how do I figure out what the heck a “perm” is? Finally, in the example looks like this:
f, err := os.OpenFile("access.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
that second argument clearly isnt an “int”, or if it is an int then I would like to understand how and why an int can look like “os.O_APPEND|os.O_CREATE|os.O_WRONLY”
Anyway sorry in advance for being a noob. I’m sure this information is out there on the internet but I’m not that good at just reading long dry manuals. Makes me nauseous. I’ll try to put back in how ever much I take out once I know this material better.