Lets say I have a folder structure like so:
src/
- main.go
data/
- example.csv
csv/
- parse.go
utils/
- mapFields.go
The mapFields function takes in input and output csv files as paramters:
MapFields(csvInPath string, csvOutPath string) {...}
I want to be able to call this mapFields function from any .go file using relative file paths. For example, from main.go:
MapFields("../data/example.csv", "../data/output.csv")
I cannot figure out how to ensure MapFields opens a csv using a path created from the file path of the calling function joined with the relative path of the csv.
I have used this stack overflow post to implement a solution to get the equivalent of __dirname in Node.js, but there is no success.
I'd appreciate any input on this.

File path is resolved in context of your current working directory.
During development it is usually the root directory of your project. You can check what is your current directory using
os.Getwd().For more flexibility consider using environment variable to indicate the root directory for your csv files. if environment variable is not set use
filepath.Join(".", "data").