mirror of
				https://github.com/joho/godotenv.git
				synced 2025-11-04 15:06:50 +00:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			multiline-
			...
			fix-godoc-
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 758dea7629 | 
							
								
								
									
										20
									
								
								godotenv.go
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								godotenv.go
									
									
									
									
									
								
							@ -30,15 +30,15 @@ const doubleQuoteSpecialChars = "\\\n\r\"!$`"
 | 
			
		||||
 | 
			
		||||
// Load will read your env file(s) and load them into ENV for this process.
 | 
			
		||||
//
 | 
			
		||||
// Call this function as close as possible to the start of your program (ideally in main)
 | 
			
		||||
// Call this function as close as possible to the start of your program (ideally in main).
 | 
			
		||||
//
 | 
			
		||||
// If you call Load without any args it will default to loading .env in the current path
 | 
			
		||||
// If you call Load without any args it will default to loading .env in the current path.
 | 
			
		||||
//
 | 
			
		||||
// You can otherwise tell it which files to load (there can be more than one) like
 | 
			
		||||
// You can otherwise tell it which files to load (there can be more than one) like:
 | 
			
		||||
//
 | 
			
		||||
//		godotenv.Load("fileone", "filetwo")
 | 
			
		||||
//
 | 
			
		||||
// It's important to note that it WILL NOT OVERRIDE an env variable that already exists - consider the .env file to set dev vars or sensible defaults
 | 
			
		||||
// It's important to note that it WILL NOT OVERRIDE an env variable that already exists - consider the .env file to set dev vars or sensible defaults.
 | 
			
		||||
func Load(filenames ...string) (err error) {
 | 
			
		||||
	filenames = filenamesOrDefault(filenames)
 | 
			
		||||
 | 
			
		||||
@ -53,11 +53,11 @@ func Load(filenames ...string) (err error) {
 | 
			
		||||
 | 
			
		||||
// Overload will read your env file(s) and load them into ENV for this process.
 | 
			
		||||
//
 | 
			
		||||
// Call this function as close as possible to the start of your program (ideally in main)
 | 
			
		||||
// Call this function as close as possible to the start of your program (ideally in main).
 | 
			
		||||
//
 | 
			
		||||
// If you call Overload without any args it will default to loading .env in the current path
 | 
			
		||||
// If you call Overload without any args it will default to loading .env in the current path.
 | 
			
		||||
//
 | 
			
		||||
// You can otherwise tell it which files to load (there can be more than one) like
 | 
			
		||||
// You can otherwise tell it which files to load (there can be more than one) like:
 | 
			
		||||
//
 | 
			
		||||
//		godotenv.Overload("fileone", "filetwo")
 | 
			
		||||
//
 | 
			
		||||
@ -124,7 +124,7 @@ func Parse(r io.Reader) (envMap map[string]string, err error) {
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//Unmarshal reads an env file from a string, returning a map of keys and values.
 | 
			
		||||
// Unmarshal reads an env file from a string, returning a map of keys and values.
 | 
			
		||||
func Unmarshal(str string) (envMap map[string]string, err error) {
 | 
			
		||||
	return Parse(strings.NewReader(str))
 | 
			
		||||
}
 | 
			
		||||
@ -132,7 +132,7 @@ func Unmarshal(str string) (envMap map[string]string, err error) {
 | 
			
		||||
// Exec loads env vars from the specified filenames (empty map falls back to default)
 | 
			
		||||
// then executes the cmd specified.
 | 
			
		||||
//
 | 
			
		||||
// Simply hooks up os.Stdin/err/out to the command and calls Run()
 | 
			
		||||
// Simply hooks up os.Stdin/err/out to the command and calls Run().
 | 
			
		||||
//
 | 
			
		||||
// If you want more fine grained control over your command it's recommended
 | 
			
		||||
// that you use `Load()` or `Read()` and the `os/exec` package yourself.
 | 
			
		||||
@ -146,7 +146,7 @@ func Exec(filenames []string, cmd string, cmdArgs []string) error {
 | 
			
		||||
	return command.Run()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Write serializes the given environment and writes it to a file
 | 
			
		||||
// Write serializes the given environment and writes it to a file.
 | 
			
		||||
func Write(envMap map[string]string, filename string) error {
 | 
			
		||||
	content, err := Marshal(envMap)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user