Last active
May 15, 2022 15:28
-
-
Save sergsoares/6c6cd50b13926c6d2294ac4bd4bfef47 to your computer and use it in GitHub Desktop.
Example in pure go of read a ENV VAR and leaving default value if not exists (In that case already convert from string to integer)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ( | |
| "os" | |
| "strconv" | |
| ) | |
| func main() { | |
| tc := 1 | |
| if temp := os.Getenv("THREADS"); temp != "" { | |
| number, err := strconv.Atoi(temp) | |
| if err != nil { | |
| panic (err) | |
| } | |
| tc = number | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment