|
3 | 3 | <a href=https://github.com/protocolbuffers/protocolbuffers.github.io/edit/main/content/reference/go/opaque-migration.md class=td-page-meta--edit target=_blank rel=noopener><i class="fa-solid fa-pen-to-square fa-fw"></i> Edit this page</a> |
4 | 4 | <a href="https://github.com/protocolbuffers/protocolbuffers.github.io/new/main/content/reference/go/opaque-migration.md?filename=change-me.md&value=---%0Atitle%3A+%22Long+Page+Title%22%0AlinkTitle%3A+%22Short+Nav+Title%22%0Aweight%3A+100%0Adescription%3A+%3E-%0A+++++Page+description+for+heading+and+indexes.%0A---%0A%0A%23%23+Heading%0A%0AEdit+this+template+to+create+your+new+page.%0A%0A%2A+Give+it+a+good+name%2C+ending+in+%60.md%60+-+e.g.+%60getting-started.md%60%0A%2A+Edit+the+%22front+matter%22+section+at+the+top+of+the+page+%28weight+controls+how+its+ordered+amongst+other+pages+in+the+same+directory%3B+lowest+number+first%29.%0A%2A+Add+a+good+commit+message+at+the+bottom+of+the+page+%28%3C80+characters%3B+use+the+extended+description+field+for+more+detail%29.%0A%2A+Create+a+new+branch+so+you+can+preview+your+new+file+and+request+a+review+via+Pull+Request.%0A" class=td-page-meta--child target=_blank rel=noopener><i class="fa-solid fa-pen-to-square fa-fw"></i> Create child page</a> |
5 | 5 | <a href="https://github.com/protocolbuffers/protocolbuffers.github.io/issues/new?title=Go%20Opaque%20API%20Migration" class=td-page-meta--issue target=_blank rel=noopener><i class="fa-solid fa-list-check fa-fw"></i> Create documentation issue</a> |
6 | | -<a href=https://github.com/protocolbuffers/protobuf/issues/new class=td-page-meta--project-issue target=_blank rel=noopener><i class="fa-solid fa-list-check fa-fw"></i> Create project issue</a></div><div class=td-toc><nav id=TableOfContents><ul><li><a href=#automated>Automated migration</a><ul><li><a href=#projectprep>Project Preparation</a></li><li><a href=#setup>Step 1. Switch to the Hybrid API</a></li><li><a href=#rewrite>Step 2. <code>open2opaque rewrite</code></a></li><li><a href=#migrate-and-verify>Step 3. Migrate and Verify</a></li></ul></li><li><a href=#questions-issues>Questions? Issues?</a></li></ul></nav></div></aside><main class="col-12 col-md-9 col-xl-8 ps-md-5" role=main><nav aria-label=breadcrumb class=td-breadcrumbs><ol class=breadcrumb><li class=breadcrumb-item><a href=/reference/>Reference Guides</a></li><li class=breadcrumb-item><a href=/reference/go/>Go</a></li><li class="breadcrumb-item active" aria-current=page>Opaque API Migration</li></ol></nav><div class=td-content><h1>Go Opaque API Migration</h1><div class=lead>Describes the automated migration to the Opaque API.</div><header class=article-meta></header><p>The Opaque API is the latest version of the Protocol Buffers implementation for |
| 6 | +<a href=https://github.com/protocolbuffers/protobuf/issues/new class=td-page-meta--project-issue target=_blank rel=noopener><i class="fa-solid fa-list-check fa-fw"></i> Create project issue</a></div><div class=td-toc><nav id=TableOfContents><ul><li><a href=#automated>Automated Migration</a><ul><li><a href=#projectprep>Project Preparation</a></li><li><a href=#setup>Step 1. Switch to the Hybrid API</a></li><li><a href=#rewrite>Step 2. <code>open2opaque rewrite</code></a></li><li><a href=#migrate-and-verify>Step 3. Migrate and Verify</a></li></ul></li><li><a href=#questions-issues>Questions? Issues?</a></li></ul></nav></div></aside><main class="col-12 col-md-9 col-xl-8 ps-md-5" role=main><nav aria-label=breadcrumb class=td-breadcrumbs><ol class=breadcrumb><li class=breadcrumb-item><a href=/reference/>Reference Guides</a></li><li class=breadcrumb-item><a href=/reference/go/>Go</a></li><li class="breadcrumb-item active" aria-current=page>Opaque API Migration</li></ol></nav><div class=td-content><h1>Go Opaque API Migration</h1><div class=lead>Describes the automated migration to the Opaque API.</div><header class=article-meta></header><p>The Opaque API is the latest version of the Protocol Buffers implementation for |
7 | 7 | the Go programming language. The old version is now called Open Struct API. See |
8 | 8 | the <a href=https://go.dev/blog/protobuf-opaque>Go Protobuf: Releasing the Opaque API</a> |
9 | 9 | blog post for an introduction.</p><p>The migration to the Opaque API happens incrementally, on a per-proto-message or |
|
29 | 29 | </span></span></code></pre></div><p>To override the default API level for a specific file (instead of all files), |
30 | 30 | use the <code>apilevelM</code> mapping flag (similar to |
31 | 31 | <a href=/reference/go/go-generated/#package>the <code>M</code> flag for import paths</a>):</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>protoc […] --go_opt=apilevelMhello.proto=API_OPEN |
32 | | -</span></span></code></pre></div><h2 id=automated>Automated migration</h2><p>We try to make migrating existing projects to the Opaque API as easy as possible |
| 32 | +</span></span></code></pre></div><h2 id=automated>Automated Migration</h2><p>We try to make migrating existing projects to the Opaque API as easy as possible |
33 | 33 | for you: our open2opaque tool does most of the work!</p><p>To install the migration tool, use:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-gdscript3 data-lang=gdscript3><span style=display:flex><span><span style=color:#000>go</span> <span style=color:#000>install</span> <span style=color:#000>google</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>golang</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>org</span><span style=color:#ce5c00;font-weight:700>/</span><span style=color:#000>open2opaque</span><span style=color:#a40000>@</span><span style=color:#000>latest</span> |
34 | 34 | </span></span><span style=display:flex><span><span style=color:#000>go</span> <span style=color:#000>install</span> <span style=color:#000>golang</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>org</span><span style=color:#ce5c00;font-weight:700>/</span><span style=color:#000>x</span><span style=color:#ce5c00;font-weight:700>/</span><span style=color:#000>tools</span><span style=color:#ce5c00;font-weight:700>/</span><span style=color:#000>cmd</span><span style=color:#ce5c00;font-weight:700>/</span><span style=color:#000>goimports</span><span style=color:#a40000>@</span><span style=color:#000>latest</span> |
35 | 35 | </span></span></code></pre></div><div class="alert alert-info" role=alert><h4 class=alert-heading>Note</h4>If |
|
0 commit comments