{"id":463,"date":"2022-10-17T08:21:04","date_gmt":"2022-10-17T00:21:04","guid":{"rendered":"https:\/\/www.db2go.net\/?p=463"},"modified":"2022-10-17T08:21:14","modified_gmt":"2022-10-17T00:21:14","slug":"%e6%b3%9b%e5%9e%8bdemo","status":"publish","type":"post","link":"https:\/\/www.db2go.net\/?p=463","title":{"rendered":"\u6cdb\u578bdemo"},"content":{"rendered":"<pre><code class=\"line-numbers\">package other\n\nimport (\n    \"fmt\"\n    \"sync\"\n    \"testing\"\n)\n\ntype ConcurrentMapShared[V any] struct {\n    items        map[string]V\n    sync.RWMutex \/\/ Read Write mutex, guards access to internal map.\n}\n\nfunc NewCM[V any]() ConcurrentMapShared[V] {\n    m := &amp;ConcurrentMapShared[V]{items: make(map[string]V)}\n    return *m\n}\n\nfunc TestName(t *testing.T) {\n\n    m := NewCM()\n    m.items[\"hah\"] = interface{}(1)\n\n    fmt.Println(m)\n}\n\n\/\/type ConcurrentMapShared struct {\n\/\/  items        map[string]interface{}\n\/\/  sync.RWMutex \/\/ Read Write mutex, guards access to internal map.\n\/\/}\n\/\/\n\/\/func NewCM() ConcurrentMapShared {\n\/\/  m := &amp;ConcurrentMapShared{items: make(map[string]interface{})}\n\/\/  return *m\n\/\/}\n\/\/\n\/\/func TestName(t *testing.T) {\n\/\/\n\/\/  m := NewCM()\n\/\/  m.items[\"hah\"] = interface{}(1)\n\/\/\n\/\/  fmt.Println(m)\n\/\/}\n\/\/\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>package other import ( &#8220;fmt&#8221; &#8220;sync&#8221; &#8220;testing&#8221; ) type Co&hellip;<\/p>\n <a href=\"https:\/\/www.db2go.net\/?p=463\" title=\"\u6cdb\u578bdemo\" class=\"entry-more-link\"><span>Read More<\/span> <span class=\"screen-reader-text\">\u6cdb\u578bdemo<\/span><\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[12],"tags":[],"class_list":["entry","author-suredandan","post-463","post","type-post","status-publish","format-standard","category-golang"],"views":1795,"_links":{"self":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/463","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=463"}],"version-history":[{"count":1,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/463\/revisions"}],"predecessor-version":[{"id":464,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/463\/revisions\/464"}],"wp:attachment":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=463"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=463"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}