Skip to content

Commit

Permalink
Improve Go library examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rossf7 authored and mrchrisadams committed Sep 21, 2023
1 parent eb075ae commit b436557
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/electricitymap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

func main() {
// Register at https://api-portal.electricitymaps.com/
token := os.Getenv("ELECTRICITY_MAP_API_TOKEN")
if token == "" {
log.Fatalln("please set the env variable `ELECTRICITY_MAP_API_TOKEN`")
Expand Down
14 changes: 12 additions & 2 deletions examples/watttime/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,26 @@ import (
"encoding/json"
"fmt"
"log"
"os"

"github.com/thegreenwebfoundation/grid-intensity-go/pkg/provider"
)

func main() {
// Register via the API
// https://www.watttime.org/api-documentation/#register-new-user
apiUser := os.Getenv("WATT_TIME_API_USER")
if apiUser == "" {
log.Fatalln("please set the env variable `WATT_TIME_API_USER`")
}
apiPassword := os.Getenv("WATT_TIME_API_PASSWORD")
if apiPassword != "" {
log.Fatalln("please set the env variable `WATT_TIME_API_PASSWORD`")
}

c := provider.WattTimeConfig{
APIUser: "your-user",
APIPassword: "your-password",
APIUser: apiUser,
APIPassword: apiPassword,
}
w, err := provider.NewWattTime(c)
if err != nil {
Expand Down

0 comments on commit b436557

Please sign in to comment.