Created
November 6, 2022 22:03
-
-
Save mainawycliffe/debc082d5a56e5e416c5eb17c5db8bb9 to your computer and use it in GitHub Desktop.
This file contains 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
// listen for changes | |
streamChanges := client.Doc("configs/config").Snapshots(ctx) | |
defer streamChanges.Stop() | |
for { | |
snap, err := streamChanges.Next() | |
if err != nil { | |
log.Fatalln(err) | |
} | |
jsonData, err := json.Marshal(snap.Data()) | |
if err != nil { | |
log.Fatalln(err) | |
} | |
viper.ReadConfig(bytes.NewBuffer(jsonData)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment