diff --git a/example-gpt-3/golang-question.sh b/example-gpt-3/golang-question.sh new file mode 100755 index 0000000..3c373ed --- /dev/null +++ b/example-gpt-3/golang-question.sh @@ -0,0 +1,16 @@ +#!/bin/bash -x + +OPENAI_API_KEY=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 + +curl https://api.openai.com/v1/completions \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $OPENAI_API_KEY" \ + -d '{ + "model": "text-davinci-003", + "prompt": "In GO, how would I list the available network interfaces?", + "temperature": 0.7, + "max_tokens": 640, + "top_p": 1.0, + "frequency_penalty": 0.0, + "presence_penalty": 0.0 +}' diff --git a/example-pprof-simple/Makefile b/example-pprof-simple/Makefile new file mode 100644 index 0000000..fa67bcf --- /dev/null +++ b/example-pprof-simple/Makefile @@ -0,0 +1,9 @@ +run: + GO111MODULE="off" go run -v -x main.go + +prep: + GO111MODULE="off" go get -v . + +build: + GO111MODULE="off" go build -v -x + # go build diff --git a/example-pprof-simple/main.go b/example-pprof-simple/main.go new file mode 100644 index 0000000..732126b --- /dev/null +++ b/example-pprof-simple/main.go @@ -0,0 +1,25 @@ +package main + +import ( + "context" + "fmt" +) + +func main() { + type favContextKey string + + f := func(ctx context.Context, k favContextKey) { + if v := ctx.Value(k); v != nil { + fmt.Println("found value:", v) + return + } + fmt.Println("key not found:", k) + } + + k := favContextKey("language") + ctx := context.WithValue(context.Background(), k, "Go") + + f(ctx, k) + f(ctx, favContextKey("color")) + +}