Created
November 29, 2017 20:43
-
-
Save GeorgeErickson/48ccfefd1b2487f4ebc7039d8d71a5b8 to your computer and use it in GitHub Desktop.
create a bare httptrace.ClientTrace implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S awk -f | |
# usage: go doc httptrace.ClientTrace | trace.awk | |
BEGIN { | |
flag=0; | |
} | |
# check if we are inside the struct. | |
/{/ { flag=1 } | |
/}/ { flag=0 } | |
# print comments as is. | |
/\/\// && flag { print $0 } | |
# manipulate func defs | |
/func/ && flag { | |
sub(/ func/, "", $0); | |
sub(/DNSStartInfo/, "si httptrace.DNSStartInfo", $0); | |
sub(/DNSDoneInfo/, "di httptrace.DNSDoneInfo", $0); | |
sub(/WroteRequestInfo/, "ri httptrace.WroteRequestInfo", $0); | |
sub(/GotConnInfo/, "ri httptrace.GotConnInfo", $0); | |
sub(/, error/, ", err error", $0); | |
print "func (t *httpTrace)", $0, "{}"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment