{"@context":"https://w3id.org/codemeta/3.0","@type":"SoftwareSourceCode","identifier":"pkg:golang/github.com/qustavo/sqlhooks/v2","name":"github.com/qustavo/sqlhooks/v2","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/qustavo/sqlhooks/v2\" \"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":"v2.1.0","softwareVersion":"v2.1.0","license":"https://spdx.org/licenses/MIT","codeRepository":"https://github.com/qustavo/sqlhooks","issueTracker":"https://github.com/qustavo/sqlhooks/issues","url":"https://github.com/qustavo/sqlhooks","programmingLanguage":{"@type":"ComputerLanguage","name":"Go"},"dateCreated":"2022-11-19","dateModified":"2021-08-08","datePublished":"2021-08-08","copyrightYear":2022,"downloadUrl":"https://proxy.golang.org/cached-only/github.com/qustavo/sqlhooks/v2/@v/v2.1.0.zip","softwareHelp":{"@type":"WebSite","url":"https://pkg.go.dev/github.com/qustavo/sqlhooks/v2#section-documentation"},"applicationCategory":"go","runtimePlatform":"go","developmentStatus":"active","sameAs":["https://pkg.go.dev/github.com/qustavo/sqlhooks/v2"],"https://www.w3.org/ns/activitystreams#likes":664,"https://forgefed.org/ns#forks":47}