{"@context":"https://w3id.org/codemeta/3.0","@type":"SoftwareSourceCode","identifier":"pkg:golang/github.com/gchaincl/sqlhooks","name":"github.com/gchaincl/sqlhooks","description":"This example shows how to instrument sql queries in order to display the time that they consume package main import ( \"context\" \"database/sql\" \"fmt\" \"time\" \"github.com/gchaincl/sqlhooks\" \"github.com/mattn/go-sqlite3\" ) // Hooks satisfies the sqlhook.Hooks interface type Hooks struct {} // Before hook will print the query with it's args and return the context with the timestamp func (h *Hooks) Before(ctx context.Context, query string, args ...interface{}) (context.Context, error) { fmt.Printf(\"\u003e %s %q\", query, args) return context.WithValue(ctx, \"begin\", time.Now()), nil } // After hook will get the timestamp registered on the Before hook and print the elapsed time func (h *Hooks) After(ctx context.Context, query string, args ...interface{}) (context.Context, error) { begin := ctx.Value(\"begin\").(time.Time) fmt.Printf(\".","version":"v1.3.0","softwareVersion":"v1.3.0","license":"https://spdx.org/licenses/MIT","codeRepository":"https://github.com/gchaincl/sqlhooks","issueTracker":"https://github.com/qustavo/sqlhooks/issues","url":"https://github.com/gchaincl/sqlhooks","programmingLanguage":{"@type":"ComputerLanguage","name":"Go"},"dateCreated":"2017-05-08","dateModified":"2019-11-25","datePublished":"2019-11-25","copyrightYear":2017,"downloadUrl":"https://proxy.golang.org/github.com/gchaincl/sqlhooks/@v/v1.3.0.zip","softwareHelp":{"@type":"WebSite","url":"https://pkg.go.dev/github.com/gchaincl/sqlhooks#section-documentation"},"applicationCategory":"go","runtimePlatform":"go","developmentStatus":"active","sameAs":["https://pkg.go.dev/github.com/gchaincl/sqlhooks"],"https://www.w3.org/ns/activitystreams#likes":602,"https://forgefed.org/ns#forks":42}