How to handle resources in a Go project?

Hi,
Say i want to write a zipcodes library which implements a FromZipCodes() function. This function parse a csv file to produce a map from zips to cities. The library code is stored in $GOPATH/src/zipcodes, along with the csv file.
Say i want to write an app which uses the zipcodes library

package main

import (
	"zipcodes"
	"fmt"
)

func main() {
	zipCodes := zipcodes.FromZipCodes()
	fmt.Println(zipCodes["95000"])
	fmt.Println(zipCodes["95800"])
}

Unfortunately, running this app fails because it does not find the csv file… I want that the csv file stays in the zipcodes project directory, not pollutes all the app directories that would need it. I don’t think it would be a good thing to force the app to give the absolute path of this file as the point of my library is to hide it…
Is it possible ?

Maybe this library can help:

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