Skip to content

Instantly share code, notes, and snippets.

@bontusss
Created December 29, 2022 00:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bontusss/d9505427a79885bb61222b85202740e9 to your computer and use it in GitHub Desktop.
Save bontusss/d9505427a79885bb61222b85202740e9 to your computer and use it in GitHub Desktop.
package main
import (
"bufio"
"fmt"
"log"
"os"
)
func main() {
apiKey := os.Getenv("BHT_APIKEY")
thesaurus := BigHuge{APIKEY: apiKey}
s := bufio.NewScanner(os.Stdin)
for s.Scan() {
word := s.Text()
syns, err := thesaurus.Synonymns(word)
if err != nil {
log.Fatal("Failed when looking for synonyms for \"" + word + "\"", err)
}
if len(syns) == 0 {
log.Fatalln("Couldn't find any synonyms for \"" + word + "\"")
}
for _, syn := range syns {
fmt.Println(syn)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment