~evanj/wtf2

0ba881fa03f3bfd93083214e5ab487ad01327893 — Evan M Jones 8 months ago 9fbc49d master
Fix(main.go): Cleaning error messages.
1 files changed, 9 insertions(+), 9 deletions(-)

M main.go
M main.go => main.go +9 -9
@@ 6,6 6,7 @@ import (
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"net/url"
	"os"


@@ 83,13 84,12 @@ func search(ctx context.Context, term string) (*definition, error) {
	return &data.List[0], nil
}

func perror(msg string, things ...interface{}) {
	fmt.Printf("wtf2: "+msg, things...)
	os.Exit(1)
}

func main() {
	log.SetPrefix("wtf2: ")
	log.SetFlags(0)

	flag.Parse()

	args := os.Args[1:]

	if len(args) > 0 && args[0] == "is" {


@@ 113,9 113,9 @@ func main() {

	maxwidth, err := strconv.Atoi(*width)
	if err != nil {
		perror("failed to parse -w max width option: %w", err)
		log.Fatalf("failed to parse -w max width option: %w", err)
	} else if maxwidth < 1 {
		perror("not a valid value for -w max width must be positive")
		log.Fatalf("not a valid value for -w max width must be positive")
	}

	var eg errgroup.Group


@@ 123,7 123,7 @@ func main() {

	timeout, err := strconv.Atoi(*timeoutStr)
	if err != nil {
		perror("failed to parse -t timeout option: %w", err)
		log.Fatalf("failed to parse -t timeout option: %w", err)
	}

	ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(timeout))


@@ 144,7 144,7 @@ func main() {
	}

	if err := eg.Wait(); err != nil {
		perror("%s", err)
		log.Fatal(err)
	}

	close(ch)