I'm creating an api with golang and zeit-now. I want the API to return a password generated from a list of words (30k). Everything works if I use a local server (http.ListenAndServe), but when I try to access the concerned endpoint with the now link, an error occurs.
I tried to use the config.includeFiles option, but it doesn't work. I also tried to use local path, absolute path but nothing is working.
Here is the now.json and randDict.go files:
now.json
"builds": [
{
"src": "/lambdas/randDict/randDict.go",
"use": "@now/go",
"config": {
"includeFiles": [
"template/wordsGist"
]
}
}
]
randDict.go
// Create a slice with the words from the words' file
func createWordsSlice() ([]string, int, error) {
// Read all the words inside the file "wordsGist"
file, err := ioutil.ReadFile("template/wordsGist")
if err != nil {
fmt.Println(err)
return nil, 0, err
}
// Split the words into a slice
words := strings.Split(string(file), "
")
return words, len(words), nil
}
Here I expect a slice with all the words, which I'll be using later for password generation, but I get an error and a empty slice (nil).
Here is the github if you want to read all the code.