Skip to content

Reference a file relative #1363

Answered by hairyhenderson
ptr1120 asked this question in Q&A
Discussion options

You must be logged in to vote

@ptr1120 is there a reason you need to use file.Read, rather than including the file as a datasource? .env type files are natively supported by gomplate...

If you do need to use file.Read though, the path is relative to your current working directory (i.e. whatever the pwd command returns). I've thought in the past of some sort of self function, which could return the template's path, or something similar, but I'm not certain how necessary it really is... Every use-case I've run into for it turned out to be a symptom of me trying to do something in an awkward and inelegant way 😉

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by ptr1120
Comment options

You must be logged in to vote
1 reply
@hairyhenderson
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants