Optimal use of Build tags

I have project which is made for cross platform support
so I am making use of build tags
I have one file in which only one costant variable name changes like and methods remain same for linux and windows
right now I am duplicating the code for both linux and windows and llinux I need some suggestion or help in refactoring this code

I have code like below

file_linux:

const logfile = "/opt/a/b/c/abc.txt"

func print(){
fmt.print(logfile)
}


file_windows:

const logfile = "C:\\a\\Amazon\\b\\c\\abc.txt"

func print(){
fmt.print(logfile)
}

Put the print in another file.go and let it use the constant from the other file

Not even the need to import if those 3 filed belong to the same package.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.