CARVIEW |
Select Language
HTTP/2 200
date: Sun, 27 Jul 2025 19:43:00 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-robots-tag: none
etag: W/"564247048e32f66405bff5b68cc97b9c"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=1M6h02nIBVZSW1CIlvo%2FJaE%2FrL7i54T6FNb1g2d%2FH8aHeLQiXpN8T96BbLScFCudVKksIyQjk5R5TmolZ483mvNVDUVa7WEFclGN3oHlM4vnWOXTRZeVx00rj%2BfqWUXK%2BCsfTVejskbLHNxa4svinuDYQ0A1kW7AgD5btgI5Ytm1qKt6AYEXMF%2F2wupSYQk0NmNzJvzJy695plmE6qFB0BNAoHbBNYvjR6hnQgSGpkbGkBjgRbYD3nKSelB9c0OmyFcSoEOny8YM2ZphqJsMow%3D%3D--nIAqwJG6ArUeJBEH--vazvHzQNmXq3sUtvBVkdrQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.287638222.1753645379; Path=/; Domain=github.com; Expires=Mon, 27 Jul 2026 19:42:59 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Mon, 27 Jul 2026 19:42:59 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: A6A2:1A1F38:1155E0C:16AF768:68868143
Working Demo · tinylib/msgp Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 196
Working Demo
Klaus Post edited this page Oct 29, 2024
·
19 revisions
1.Make a temporary folder for this demo
$ mkdir temp
2.Install the msgp processor
$ go install github.com/tinylib/msgp@latest
3.Open editor and copy/paste and save the code below:
package main
import (
"fmt"
)
//go:generate msgp
type QryD struct {
A int8
D int8
T string
K string
V string
}
func main() {
fmt.Println("Nothing to see here yet!")
}
4.Run the following command: (this is important as it generates a "template" for your msgp variables defined above)
$ go generate
5.Two more files are generated here, main_gen.go and main_gen_test.go , verify by typing
$ ls -al
6.Replace all content of main.go by copy pasting these lines:
package main
import (
"fmt"
)
//go:generate msgp
type QryD struct {
A int8
D int8
T string
K string
V string
}
func main() {
var valuePlaceholder QryD
v := QryD{A: 1, D: 9, T: "table", K: "key", V: "value"}
bts, err := v.MarshalMsg(nil)
if err != nil {
// fmt.Println(err) // print err or log error information
}
leftovervalues, err := valuePlaceholder.UnmarshalMsg(bts) // purpose of lefovervalues, pls read doc.
fmt.Println(leftovervalues)
// leftovervalues is empty because bts only contained one object.
fmt.Println(valuePlaceholder)
fmt.Println(valuePlaceholder.A)
fmt.Println(valuePlaceholder.D)
fmt.Println(valuePlaceholder.T)
fmt.Println(valuePlaceholder.K)
fmt.Println(valuePlaceholder.V)
if err != nil {
fmt.Printf("error: %s\n", err)
}
}
7.Run the following lines to generate "main" executable:
$ go build main.go main_gen.go
8.Run the program
$ ./main
9.You should see
[]
{1 9 table key value}
1
9
table
key
value
Nothing to see here yet!
10.That's it!
You can’t perform that action at this time.