MCPcopy
hub / github.com/gobyexample-cn/gobyexample / resetURLHashFile

Function resetURLHashFile

tools/generate.go:122–136  ·  view source on GitHub ↗
(codehash, code, sourcePath string)

Source from the content-addressed store, hash-verified

120}
121
122func resetURLHashFile(codehash, code, sourcePath string) string {
123 if verbose() {
124 fmt.Println(" Sending request to play.golang.org")
125 }
126 payload := strings.NewReader(code)
127 resp, err := http.Post("https://play.golang.org/share", "text/plain", payload)
128 check(err)
129 defer resp.Body.Close()
130 body, err := io.ReadAll(resp.Body)
131 check(err)
132 urlkey := string(body)
133 data := fmt.Sprintf("%s\n%s\n", codehash, urlkey)
134 os.WriteFile(sourcePath, []byte(data), 0644)
135 return urlkey
136}
137
138func parseSegs(sourcePath string) ([]*Seg, string) {
139 var (

Callers 1

parseExamplesFunction · 0.85

Calls 2

verboseFunction · 0.85
checkFunction · 0.70

Tested by

no test coverage detected