CINXE.COM
cgo command - cmd/cgo - Go Packages
<!DOCTYPE html> <html lang="en" data-layout="responsive" data-local=""> <head> <script> window.addEventListener('error', window.__err=function f(e){f.p=f.p||[];f.p.push(e)}); </script> <script> (function() { const theme = document.cookie.match(/prefers-color-scheme=(light|dark|auto)/)?.[1] if (theme) { document.querySelector('html').setAttribute('data-theme', theme); } }()) </script> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="Description" content="Cgo enables the creation of Go packages that call C code."> <meta class="js-gtmID" data-gtmid="GTM-W8MVQXG"> <link rel="shortcut icon" href="/static/shared/icon/favicon.ico"> <link rel="canonical" href="https://pkg.go.dev/cmd/cgo"> <link href="/static/frontend/frontend.min.css?version=prod-frontend-00098-h5t" rel="stylesheet"> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Go Packages"> <title>cgo command - cmd/cgo - Go Packages</title> <link href="/static/frontend/unit/unit.min.css?version=prod-frontend-00098-h5t" rel="stylesheet"> <link href="/static/frontend/unit/main/main.min.css?version=prod-frontend-00098-h5t" rel="stylesheet"> </head> <body> <script> function loadScript(src, mod = true) { let s = document.createElement('script'); s.src = src; if (mod) { s.type = 'module'; s.async = true; s.defer = true } document.head.appendChild(s); } loadScript("/third_party/dialog-polyfill/dialog-polyfill.js", false) loadScript("/static/frontend/frontend.js"); </script> <header class="go-Header go-Header--full js-siteHeader"> <div class="go-Header-inner go-Header-inner--dark"> <nav class="go-Header-nav"> <a href="https://go.dev/" class="js-headerLogo" data-gtmc="nav link" data-test-id="go-header-logo-link" role="heading" aria-level="1"> <img class="go-Header-logo" src="/static/shared/logo/go-white.svg" alt="Go"> </a> <div class="skip-navigation-wrapper"> <a class="skip-to-content-link" aria-label="Skip to main content" href="#main-content"> Skip to Main Content </a> </div> <div class="go-Header-rightContent"> <div class="go-SearchForm js-searchForm"> <form class="go-InputGroup go-ShortcutKey go-SearchForm-form" action="/search" data-shortcut="/" data-shortcut-alt="search" data-gtmc="search form" aria-label="Search for a package" role="search" > <input name="q" class="go-Input js-searchFocus" aria-label="Search for a package" type="search" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false" placeholder="Search packages or symbols" value="" /> <input name="m" value="" hidden> <button class="go-Button go-Button--inverted" aria-label="Submit search"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/search_gm_grey_24dp.svg" alt="" /> </button> </form> <button class="go-SearchForm-expandSearch js-expandSearch" data-gtmc="nav button" aria-label="Open search" data-test-id="expand-search"> <img class="go-Icon go-Icon--inverted" height="24" width="24" src="/static/shared/icon/search_gm_grey_24dp.svg" alt=""> </button> </div> <ul class="go-Header-menu"> <li class="go-Header-menuItem"> <a class="js-desktop-menu-hover" href="#" data-gtmc="nav link"> Why Go <img class="go-Icon" height="24" width="24" src="/static/shared/icon/arrow_drop_down_gm_grey_24dp.svg" alt="submenu dropdown icon"> </a> <ul class="go-Header-submenu go-Header-submenu--why js-desktop-submenu-hover" aria-label="submenu"> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/solutions#case-studies"> <span>Case Studies</span> </a> </div> <p>Common problems companies solve with Go</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/solutions#use-cases"> <span>Use Cases</span> </a> </div> <p>Stories about how and why companies use Go</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/security/"> <span>Security</span> </a> </div> <p>How Go can help keep you secure by default</p> </li> </ul> </li> <li class="go-Header-menuItem"> <a href="https://go.dev/learn/" data-gtmc="nav link">Learn</a> </li> <li class="go-Header-menuItem"> <a class="js-desktop-menu-hover" href="#" data-gtmc="nav link"> Docs <img class="go-Icon" height="24" width="24" src="/static/shared/icon/arrow_drop_down_gm_grey_24dp.svg" alt="submenu dropdown icon"> </a> <ul class="go-Header-submenu go-Header-submenu--docs js-desktop-submenu-hover" aria-label="submenu"> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/doc/effective_go"> <span>Effective Go</span> </a> </div> <p>Tips for writing clear, performant, and idiomatic Go code</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/doc/"> <span>Go User Manual</span> </a> </div> <p>A complete introduction to building software with Go</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://pkg.go.dev/std"> <span>Standard library</span> </a> </div> <p>Reference documentation for Go's standard library</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/doc/devel/release"> <span>Release Notes</span> </a> </div> <p>Learn what's new in each Go release</p> </li> </ul> </li> <li class="go-Header-menuItem go-Header-menuItem--active"> <a href="/" data-gtmc="nav link">Packages</a> </li> <li class="go-Header-menuItem"> <a class="js-desktop-menu-hover" href="#" data-gtmc="nav link"> Community <img class="go-Icon" height="24" width="24" src="/static/shared/icon/arrow_drop_down_gm_grey_24dp.svg" alt="submenu dropdown icon"> </a> <ul class="go-Header-submenu go-Header-submenu--community js-desktop-submenu-hover" aria-label="submenu"> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/talks/"> <span>Recorded Talks</span> </a> </div> <p>Videos from prior events</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://www.meetup.com/pro/go"> <span>Meetups</span> <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/launch_gm_grey_24dp.svg" alt=""> </i> </a> </div> <p>Meet other local Go developers</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://github.com/golang/go/wiki/Conferences"> <span>Conferences</span> <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/launch_gm_grey_24dp.svg" alt=""> </i> </a> </div> <p>Learn and network with Go developers from around the world</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/blog"> <span>Go blog</span> </a> </div> <p>The Go project's official blog.</p> </li> <li class="go-Header-submenuItem"> <div> <a href="https://go.dev/help"> <span>Go project</span> </a> </div> <p>Get help and stay informed from Go</p> </li> <li class="go-Header-submenuItem"> <div> Get connected </div> <p></p> <div class="go-Header-socialIcons"> <a class="go-Header-socialIcon" aria-label="Get connected with google-groups (Opens in new window)" title="Get connected with google-groups (Opens in new window)" href="https://groups.google.com/g/golang-nuts"> <img src="/static/shared/logo/social/google-groups.svg" /> </a> <a class="go-Header-socialIcon" aria-label="Get connected with github (Opens in new window)" title="Get connected with github (Opens in new window)" href="https://github.com/golang"> <img src="/static/shared/logo/social/github.svg" /> </a> <a class="go-Header-socialIcon" aria-label="Get connected with twitter (Opens in new window)" title="Get connected with twitter (Opens in new window)" href="https://twitter.com/golang"> <img src="/static/shared/logo/social/twitter.svg" /> </a> <a class="go-Header-socialIcon" aria-label="Get connected with reddit (Opens in new window)" title="Get connected with reddit (Opens in new window)" href="https://www.reddit.com/r/golang/"> <img src="/static/shared/logo/social/reddit.svg" /> </a> <a class="go-Header-socialIcon" aria-label="Get connected with slack (Opens in new window)" title="Get connected with slack (Opens in new window)" href="https://invite.slack.golangbridge.org/"> <img src="/static/shared/logo/social/slack.svg" /> </a> <a class="go-Header-socialIcon" aria-label="Get connected with stack-overflow (Opens in new window)" title="" href="https://stackoverflow.com/collectives/go"> <img src="/static/shared/logo/social/stack-overflow.svg" /> </a> </div> </li> </ul> </li> </ul> <button class="go-Header-navOpen js-headerMenuButton go-Header-navOpen--white" data-gtmc="nav button" aria-label="Open navigation"> </button> </div> </nav> </div> </header> <aside class="go-NavigationDrawer js-header"> <nav class="go-NavigationDrawer-nav"> <div class="go-NavigationDrawer-header"> <a href="https://go.dev/"> <img class="go-NavigationDrawer-logo" src="/static/shared/logo/go-blue.svg" alt="Go."> </a> </div> <ul class="go-NavigationDrawer-list"> <li class="go-NavigationDrawer-listItem js-mobile-subnav-trigger go-NavigationDrawer-hasSubnav"> <a href="#"> <span>Why Go</span> <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/navigate_next_gm_grey_24dp.svg" alt=""> </i> </a> <div class="go-NavigationDrawer go-NavigationDrawer-submenuItem"> <div class="go-NavigationDrawer-nav"> <div class="go-NavigationDrawer-header"> <a href="#"> <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/navigate_before_gm_grey_24dp.svg" alt=""> </i> Why Go </a> </div> <ul class="go-NavigationDrawer-list"> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/solutions#case-studies"> Case Studies </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/solutions#use-cases"> Use Cases </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/security/"> Security </a> </li> </ul> </div> </div> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/learn/">Learn</a> </li> <li class="go-NavigationDrawer-listItem js-mobile-subnav-trigger go-NavigationDrawer-hasSubnav"> <a href="#"> <span>Docs</span> <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/navigate_next_gm_grey_24dp.svg" alt=""> </i> </a> <div class="go-NavigationDrawer go-NavigationDrawer-submenuItem"> <div class="go-NavigationDrawer-nav"> <div class="go-NavigationDrawer-header"> <a href="#"><i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/navigate_before_gm_grey_24dp.svg" alt=""> </i> Docs </a> </div> <ul class="go-NavigationDrawer-list"> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/doc/effective_go"> Effective Go </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/doc/"> Go User Manual </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://pkg.go.dev/std"> Standard library </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/doc/devel/release"> Release Notes </a> </li> </ul> </div> </div> </li> <li class="go-NavigationDrawer-listItem go-NavigationDrawer-listItem--active"> <a href="/">Packages</a> </li> <li class="go-NavigationDrawer-listItem js-mobile-subnav-trigger go-NavigationDrawer-hasSubnav"> <a href="#"> <span>Community</span> <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/navigate_next_gm_grey_24dp.svg" alt=""> </i> </a> <div class="go-NavigationDrawer go-NavigationDrawer-submenuItem"> <div class="go-NavigationDrawer-nav"> <div class="go-NavigationDrawer-header"> <a href="#"> <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/navigate_before_gm_grey_24dp.svg" alt=""> </i> Community </a> </div> <ul class="go-NavigationDrawer-list"> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/talks/"> Recorded Talks </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://www.meetup.com/pro/go"> Meetups <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/launch_gm_grey_24dp.svg" alt=""> </i> </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://github.com/golang/go/wiki/Conferences"> Conferences <i class="material-icons"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/launch_gm_grey_24dp.svg" alt=""> </i> </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/blog"> Go blog </a> </li> <li class="go-NavigationDrawer-listItem"> <a href="https://go.dev/help"> Go project </a> </li> <li class="go-NavigationDrawer-listItem"> <div>Get connected</div> <div class="go-Header-socialIcons"> <a class="go-Header-socialIcon" href="https://groups.google.com/g/golang-nuts"><img src="/static/shared/logo/social/google-groups.svg" /></a> <a class="go-Header-socialIcon" href="https://github.com/golang"><img src="/static/shared/logo/social/github.svg" /></a> <a class="go-Header-socialIcon" href="https://twitter.com/golang"><img src="/static/shared/logo/social/twitter.svg" /></a> <a class="go-Header-socialIcon" href="https://www.reddit.com/r/golang/"><img src="/static/shared/logo/social/reddit.svg" /></a> <a class="go-Header-socialIcon" href="https://invite.slack.golangbridge.org/"><img src="/static/shared/logo/social/slack.svg" /></a> <a class="go-Header-socialIcon" href="https://stackoverflow.com/collectives/go"><img src="/static/shared/logo/social/stack-overflow.svg" /></a> </div> </li> </ul> </div> </div> </li> </ul> </nav> </aside> <div class="go-NavigationDrawer-scrim js-scrim" role="presentation"></div> <main class="go-Main" id="main-content"> <div class="go-Main-banner" role="alert"></div> <header class="go-Main-header js-mainHeader"> <nav class="go-Main-headerBreadcrumb go-Breadcrumb" aria-label="Breadcrumb" data-test-id="UnitHeader-breadcrumb"> <ol> <li data-test-id="UnitHeader-breadcrumbItem"> <a href="/" data-gtmc="breadcrumb link">Discover Packages</a> </li> <li data-test-id="UnitHeader-breadcrumbItem"> <a href="/std" data-gtmc="breadcrumb link">Standard library</a> </li> <li data-test-id="UnitHeader-breadcrumbItem"> <a href="/cmd" data-gtmc="breadcrumb link">cmd</a> </li> <li> <a href="/cmd/cgo@go1.24.2" data-gtmc="breadcrumb link" aria-current="location" data-test-id="UnitHeader-breadcrumbCurrent"> cgo </a> <button class="go-Button go-Button--inline go-Clipboard js-clipboard" title="Copy path to clipboard. cmd/cgo" aria-label="Copy Path to Clipboard" data-to-copy="cmd/cgo" data-gtmc="breadcrumbs button" > <img class="go-Icon go-Icon--accented" height="24" width="24" src="/static/shared/icon/content_copy_gm_grey_24dp.svg" alt="" > </button> </li> </ol> </nav> <div class="go-Main-headerContent"> <div class="go-Main-headerTitle js-stickyHeader"> <a class="go-Main-headerLogo" href="https://go.dev/" aria-hidden="true" tabindex="-1" data-gtmc="header link" aria-label="Link to Go Homepage"> <img height="78" width="207" src="/static/shared/logo/go-blue.svg" alt="Go"> </a> <h1 class="UnitHeader-titleHeading" data-test-id="UnitHeader-title">cgo</h1> <span class="go-Chip go-Chip--inverted">command</span> <span class="go-Chip go-Chip--inverted">standard library</span> <button class="go-Button go-Button--inline go-Clipboard js-clipboard" title="Copy path to clipboard. cmd/cgo" aria-label="Copy Path to Clipboard" data-to-copy="cmd/cgo" data-gtmc="title button" tabindex="-1" > <img class="go-Icon go-Icon--accented" height="24" width="24" src="/static/shared/icon/content_copy_gm_grey_24dp.svg" alt="" /> </button> </div> <div class="go-Main-headerDetails"> <span class="go-Main-headerDetailItem" data-test-id="UnitHeader-version"> <a href="?tab=versions" aria-label="Version: go1.24.2" data-gtmc="header link" aria-describedby="version-description"> <span class="go-textSubtle" aria-hidden="true">Version: </span> go1.24.2 </a> <div class="screen-reader-only" id="version-description" hidden> Opens a new window with list of versions in this module. </div> <span class="DetailsHeader-badge--latest" data-test-id="UnitHeader-minorVersionBanner"> <span class="go-Chip DetailsHeader-span--latest">Latest</span> <span class="go-Chip DetailsHeader-span--notAtLatest"> Latest <details class="go-Tooltip js-tooltip" data-gtmc="tooltip"> <summary> <img class="go-Icon go-Icon--inverted" height="24" width="24" src="/static/shared/icon/alert_gm_grey_24dp.svg" alt="Warning"> </summary> <p>This package is not in the latest version of its module.</p> </details> </span> <a href="/cmd/cgo" aria-label="Go to Latest Version" data-gtmc="header link"> <span class="go-Chip go-Chip--alert DetailsHeader-span--goToLatest">Go to latest</span> </a> </span> </span> <span class="go-Main-headerDetailItem" data-test-id="UnitHeader-commitTime"> Published: Apr 1, 2025 </span> <span class="go-Main-headerDetailItem" data-test-id="UnitHeader-licenses"> License: <a href="/cmd/cgo?tab=licenses" data-test-id="UnitHeader-license" data-gtmc="header link" aria-describedby="license-description">BSD-3-Clause</a> </span> <div class="screen-reader-only" id="license-description" hidden> Opens a new window with license information. </div> <span class="go-Main-headerDetailItem" data-test-id="UnitHeader-imports"> <a href="/cmd/cgo?tab=imports" aria-label="Imports: 39" data-gtmc="header link" aria-describedby="imports-description"> <span class="go-textSubtle">Imports: </span>39 </a> </span> <div class="screen-reader-only" id="imports-description" hidden> Opens a new window with list of imports. </div> <span class="go-Main-headerDetailItem" data-test-id="UnitHeader-importedby"> <a href="/cmd/cgo?tab=importedby" aria-label="Imported By: 0" data-gtmc="header link" aria-describedby="importedby-description"> <span class="go-textSubtle">Imported by: </span>0 </a> </span> <div class="screen-reader-only" id="importedby-description" hidden> Opens a new window with list of known importers. </div> </div> <div class="UnitHeader-overflowContainer"> <svg class="UnitHeader-overflowImage" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"> <path d="M0 0h24v24H0z" fill="none"/> <path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/> </svg> <select class="UnitHeader-overflowSelect js-selectNav" tabindex="-1"> <option value="/">Main</option> <option value="/cmd/cgo?tab=versions"> Versions </option> <option value="/cmd/cgo?tab=licenses"> Licenses </option> <option value="/cmd/cgo?tab=imports"> Imports </option> <option value="/cmd/cgo?tab=importedby"> Imported By </option> </select> </div> </div> </header> <aside class="go-Main-aside js-mainAside"> <div class="UnitMeta"> <h2 class="go-textLabel">Details</h2> <ul class="UnitMeta-details"> <li> <details class="go-Tooltip js-tooltip" data-gtmc="tooltip"> <summary class="go-textSubtle"> <img class="go-Icon go-Icon--accented" tabindex="0" role="button"src="/static/shared/icon/check_circle_gm_grey_24dp.svg" alt="checked" aria-label="Valid file, toggle tooltip"height="24" width="24"> Valid <a href="https://cs.opensource.google/go/go/+/go1.24.2:src/go.mod" target="_blank" rel="noopener">go.mod</a> file <img class="go-Icon" role="button" tabindex="0" src="/static/shared/icon/help_gm_grey_24dp.svg" alt="" aria-label="Toggle go.mod validity tooltip" height="24" width="24"> </summary> <p aria-live="polite" role="tooltip"> The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go. </p> </details> </li> <li> <details class="go-Tooltip js-tooltip" data-gtmc="tooltip"> <summary class="go-textSubtle"> <img class="go-Icon go-Icon--accented" tabindex="0" role="button"src="/static/shared/icon/check_circle_gm_grey_24dp.svg" alt="checked" aria-label="Valid file, toggle tooltip"height="24" width="24"> Redistributable license <img class="go-Icon" role="button" tabindex="0" src="/static/shared/icon/help_gm_grey_24dp.svg" alt="" aria-label="Toggle redistributable help tooltip" height="24" width="24"> </summary> <p aria-live="polite" role="tooltip"> Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed. </p> </details> </li> <li> <details class="go-Tooltip js-tooltip" data-gtmc="tooltip"> <summary class="go-textSubtle"> <img class="go-Icon go-Icon--accented" tabindex="0" role="button"src="/static/shared/icon/check_circle_gm_grey_24dp.svg" alt="checked" aria-label="Valid file, toggle tooltip"height="24" width="24"> Tagged version <img class="go-Icon" role="button" tabindex="0" src="/static/shared/icon/help_gm_grey_24dp.svg" alt="" aria-label="Toggle tagged version tooltip" height="24" width="24"> </summary> <p aria-live="polite" role="tooltip">Modules with tagged versions give importers more predictable builds.</p> </details> </li> <li> <details class="go-Tooltip js-tooltip" data-gtmc="tooltip"> <summary class="go-textSubtle"> <img class="go-Icon go-Icon--accented" tabindex="0" role="button"src="/static/shared/icon/check_circle_gm_grey_24dp.svg" alt="checked" aria-label="Valid file, toggle tooltip"height="24" width="24"> Stable version <img class="go-Icon" role="button" tabindex="0" aria-label="Toggle stable version tooltip" src="/static/shared/icon/help_gm_grey_24dp.svg" alt="" height="24" width="24"> </summary> <p aria-live="polite" role="tooltip">When a project reaches major version v1 it is considered stable.</p> </details> </li> <li class="UnitMeta-detailsLearn"> <a href="/about#best-practices" data-gtmc="meta link">Learn more about best practices</a> </li> </ul> <h2 class="go-textLabel">Repository</h2> <div class="UnitMeta-repo"> <a href="https://cs.opensource.google/go/go" title="https://cs.opensource.google/go/go" target="_blank" rel="noopener"> cs.opensource.google/go/go </a> </div> <h2 class="go-textLabel" data-test-id="links-heading">Links</h2> <ul class="UnitMeta-links"> <li> <a href="https://go.dev/security/policy" title="Report security issues in the Go standard library and sub-repositories"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/security_grey_24dp.svg" alt=""> Report a Vulnerability </a> </li> </ul> </div> </aside> <nav class="go-Main-nav go-Main-nav--sticky js-mainNav" aria-label="Outline"> <div class="go-Main-navDesktop"> <div class="UnitOutline-jumpTo"> <button class="UnitOutline-jumpToInput go-ShortcutKey js-jumpToInput" aria-controls="jump-to-modal" aria-label="Open Jump to Identifier" data-shortcut="f" data-shortcut-alt="find" data-test-id="jump-to-button" data-gtmc="outline button"> Jump to ... </button> </div> <ul class="go-Tree js-tree" role="tree" aria-label="Outline"> <li> <a href="#section-documentation" data-gtmc="outline link"> Documentation </a> <ul> <li> <a href="#pkg-overview" data-gtmc="doc outline link">Overview</a> </li> </ul> </li> <li> <a href="#section-sourcefiles" data-gtmc="outline link"> Source Files </a> </li> <li> <a href="#section-directories" data-gtmc="outline link"> Directories </a> </li> </ul> </div> <div class="go-Main-navMobile js-mainNavMobile"> <label class="go-Label"> <select class="go-Select"> <option selected disabled>Documentation</option> </select> </label> </div> </nav> <article class="go-Main-article js-mainContent"> <div class="UnitDetails" data-test-id="UnitDetails" style="display: block;"> <div class="UnitDetails-content js-unitDetailsContent" data-test-id="UnitDetails-content"> <div class="UnitDoc"> <h2 class="UnitDoc-title" id="section-documentation"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/code_gm_grey_24dp.svg" alt=""> Documentation <a class="UnitDoc-idLink" href="#section-documentation" title="Go to Documentation" aria-label="Go to Documentation">露</a> </h2> <div class="Documentation js-documentation"> <div class="Documentation-content js-docContent"> <section class="Documentation-overview"> <h3 tabindex="-1" id="pkg-overview" class="Documentation-overviewHeader">Overview <a href="#pkg-overview" title="Go to Overview" aria-label="Go to Overview">露</a></h3> <div role="navigation" aria-label="Table of Contents"> <ul class="Documentation-toc Documentation-toc-columns"> <li class="Documentation-tocItem"><a href="#hdr-Using_cgo_with_the_go_command">Using cgo with the go command</a></li> <li class="Documentation-tocItem"><a href="#hdr-Go_references_to_C">Go references to C</a></li> <li class="Documentation-tocItem"><a href="#hdr-C_references_to_Go">C references to Go</a></li> <li class="Documentation-tocItem"><a href="#hdr-Passing_pointers">Passing pointers</a></li> <li class="Documentation-tocItem"><a href="#hdr-Optimizing_calls_of_C_code">Optimizing calls of C code</a></li> <li class="Documentation-tocItem"><a href="#hdr-Special_cases">Special cases</a></li> <li class="Documentation-tocItem"><a href="#hdr-Using_cgo_directly">Using cgo directly</a></li> </ul> </div> <p>Cgo enables the creation of Go packages that call C code. </p><h4 id="hdr-Using_cgo_with_the_go_command">Using cgo with the go command <a class="Documentation-idLink" href="#hdr-Using_cgo_with_the_go_command" title="Go to Using cgo with the go command" aria-label="Go to Using cgo with the go command">露</a></h4><p>To use cgo write normal Go code that imports a pseudo-package "C". The Go code can then refer to types such as C.size_t, variables such as C.stdout, or functions such as C.putchar. </p><p>If the import of "C" is immediately preceded by a comment, that comment, called the preamble, is used as a header when compiling the C parts of the package. For example: </p><pre>// #include <stdio.h> // #include <errno.h> import "C" </pre><p>The preamble may contain any C code, including function and variable declarations and definitions. These may then be referred to from Go code as though they were defined in the package "C". All names declared in the preamble may be used, even if they start with a lower-case letter. Exception: static variables in the preamble may not be referenced from Go code; static functions are permitted. </p><p>See $GOROOT/cmd/cgo/internal/teststdio and $GOROOT/misc/cgo/gmp for examples. See "C? Go? Cgo!" for an introduction to using cgo: <a href="https://golang.org/doc/articles/c_go_cgo.html">https://golang.org/doc/articles/c_go_cgo.html</a>. </p><p>CFLAGS, CPPFLAGS, CXXFLAGS, FFLAGS and LDFLAGS may be defined with pseudo #cgo directives within these comments to tweak the behavior of the C, C++ or Fortran compiler. Values defined in multiple directives are concatenated together. The directive can include a list of build constraints limiting its effect to systems satisfying one of the constraints (see <a href="https://golang.org/pkg/go/build/#hdr-Build_Constraints">https://golang.org/pkg/go/build/#hdr-Build_Constraints</a> for details about the constraint syntax). For example: </p><pre>// #cgo CFLAGS: -DPNG_DEBUG=1 // #cgo amd64 386 CFLAGS: -DX86=1 // #cgo LDFLAGS: -lpng // #include <png.h> import "C" </pre><p>Alternatively, CPPFLAGS and LDFLAGS may be obtained via the pkg-config tool using a '#cgo pkg-config:' directive followed by the package names. For example: </p><pre>// #cgo pkg-config: png cairo // #include <png.h> import "C" </pre><p>The default pkg-config tool may be changed by setting the PKG_CONFIG environment variable. </p><p>For security reasons, only a limited set of flags are allowed, notably -D, -U, -I, and -l. To allow additional flags, set CGO_CFLAGS_ALLOW to a regular expression matching the new flags. To disallow flags that would otherwise be allowed, set CGO_CFLAGS_DISALLOW to a regular expression matching arguments that must be disallowed. In both cases the regular expression must match a full argument: to allow -mfoo=bar, use CGO_CFLAGS_ALLOW='-mfoo.*', not just CGO_CFLAGS_ALLOW='-mfoo'. Similarly named variables control the allowed CPPFLAGS, CXXFLAGS, FFLAGS, and LDFLAGS. </p><p>Also for security reasons, only a limited set of characters are permitted, notably alphanumeric characters and a few symbols, such as '.', that will not be interpreted in unexpected ways. Attempts to use forbidden characters will get a "malformed #cgo argument" error. </p><p>When building, the CGO_CFLAGS, CGO_CPPFLAGS, CGO_CXXFLAGS, CGO_FFLAGS and CGO_LDFLAGS environment variables are added to the flags derived from these directives. Package-specific flags should be set using the directives, not the environment variables, so that builds work in unmodified environments. Flags obtained from environment variables are not subject to the security limitations described above. </p><p>All the cgo CPPFLAGS and CFLAGS directives in a package are concatenated and used to compile C files in that package. All the CPPFLAGS and CXXFLAGS directives in a package are concatenated and used to compile C++ files in that package. All the CPPFLAGS and FFLAGS directives in a package are concatenated and used to compile Fortran files in that package. All the LDFLAGS directives in any package in the program are concatenated and used at link time. All the pkg-config directives are concatenated and sent to pkg-config simultaneously to add to each appropriate set of command-line flags. </p><p>When the cgo directives are parsed, any occurrence of the string ${SRCDIR} will be replaced by the absolute path to the directory containing the source file. This allows pre-compiled static libraries to be included in the package directory and linked properly. For example if package foo is in the directory /go/src/foo: </p><pre>// #cgo LDFLAGS: -L${SRCDIR}/libs -lfoo </pre><p>Will be expanded to: </p><pre>// #cgo LDFLAGS: -L/go/src/foo/libs -lfoo </pre><p>When the Go tool sees that one or more Go files use the special import "C", it will look for other non-Go files in the directory and compile them as part of the Go package. Any .c, .s, .S or .sx files will be compiled with the C compiler. Any .cc, .cpp, or .cxx files will be compiled with the C++ compiler. Any .f, .F, .for or .f90 files will be compiled with the fortran compiler. Any .h, .hh, .hpp, or .hxx files will not be compiled separately, but, if these header files are changed, the package (including its non-Go source files) will be recompiled. Note that changes to files in other directories do not cause the package to be recompiled, so all non-Go source code for the package should be stored in the package directory, not in subdirectories. The default C and C++ compilers may be changed by the CC and CXX environment variables, respectively; those environment variables may include command line options. </p><p>The cgo tool will always invoke the C compiler with the source file's directory in the include path; i.e. -I${SRCDIR} is always implied. This means that if a header file foo/bar.h exists both in the source directory and also in the system include directory (or some other place specified by a -I flag), then "#include <foo/bar.h>" will always find the local version in preference to any other version. </p><p>The cgo tool is enabled by default for native builds on systems where it is expected to work. It is disabled by default when cross-compiling as well as when the CC environment variable is unset and the default C compiler (typically gcc or clang) cannot be found on the system PATH. You can override the default by setting the CGO_ENABLED environment variable when running the go tool: set it to 1 to enable the use of cgo, and to 0 to disable it. The go tool will set the build constraint "cgo" if cgo is enabled. The special import "C" implies the "cgo" build constraint, as though the file also said "//go:build cgo". Therefore, if cgo is disabled, files that import "C" will not be built by the go tool. (For more about build constraints see <a href="https://golang.org/pkg/go/build/#hdr-Build_Constraints">https://golang.org/pkg/go/build/#hdr-Build_Constraints</a>). </p><p>When cross-compiling, you must specify a C cross-compiler for cgo to use. You can do this by setting the generic CC_FOR_TARGET or the more specific CC_FOR_${GOOS}_${GOARCH} (for example, CC_FOR_linux_arm) environment variable when building the toolchain using make.bash, or you can set the CC environment variable any time you run the go tool. </p><p>The CXX_FOR_TARGET, CXX_FOR_${GOOS}_${GOARCH}, and CXX environment variables work in a similar way for C++ code. </p><h4 id="hdr-Go_references_to_C">Go references to C <a class="Documentation-idLink" href="#hdr-Go_references_to_C" title="Go to Go references to C" aria-label="Go to Go references to C">露</a></h4><p>Within the Go file, C's struct field names that are keywords in Go can be accessed by prefixing them with an underscore: if x points at a C struct with a field named "type", x._type accesses the field. C struct fields that cannot be expressed in Go, such as bit fields or misaligned data, are omitted in the Go struct, replaced by appropriate padding to reach the next field or the end of the struct. </p><p>The standard C numeric types are available under the names C.char, C.schar (signed char), C.uchar (unsigned char), C.short, C.ushort (unsigned short), C.int, C.uint (unsigned int), C.long, C.ulong (unsigned long), C.longlong (long long), C.ulonglong (unsigned long long), C.float, C.double, C.complexfloat (complex float), and C.complexdouble (complex double). The C type void* is represented by Go's unsafe.Pointer. The C types __int128_t and __uint128_t are represented by [16]byte. </p><p>A few special C types which would normally be represented by a pointer type in Go are instead represented by a uintptr. See the Special cases section below. </p><p>To access a struct, union, or enum type directly, prefix it with struct_, union_, or enum_, as in C.struct_stat. The size of any C type T is available as C.sizeof_T, as in C.sizeof_struct_stat. These special prefixes means that there is no way to directly reference a C identifier that starts with "struct_", "union_", "enum_", or "sizeof_", such as a function named "struct_function". A workaround is to use a "#define" in the preamble, as in "#define c_struct_function struct_function" and then in the Go code refer to "C.c_struct_function". </p><p>A C function may be declared in the Go file with a parameter type of the special name _GoString_. This function may be called with an ordinary Go string value. The string length, and a pointer to the string contents, may be accessed by calling the C functions </p><pre>size_t _GoStringLen(_GoString_ s); const char *_GoStringPtr(_GoString_ s); </pre><p>These functions are only available in the preamble, not in other C files. The C code must not modify the contents of the pointer returned by _GoStringPtr. Note that the string contents may not have a trailing NUL byte. </p><p>As Go doesn't have support for C's union type in the general case, C's union types are represented as a Go byte array with the same length. </p><p>Go structs cannot embed fields with C types. </p><p>Go code cannot refer to zero-sized fields that occur at the end of non-empty C structs. To get the address of such a field (which is the only operation you can do with a zero-sized field) you must take the address of the struct and add the size of the struct. </p><p>Cgo translates C types into equivalent unexported Go types. Because the translations are unexported, a Go package should not expose C types in its exported API: a C type used in one Go package is different from the same C type used in another. </p><p>Any C function (even void functions) may be called in a multiple assignment context to retrieve both the return value (if any) and the C errno variable as an error (use _ to skip the result value if the function returns void). For example: </p><pre>n, err = C.sqrt(-1) _, err := C.voidFunc() var n, err = C.sqrt(1) </pre><p>Note that the C errno value may be non-zero, and thus the err result may be non-nil, even if the function call is successful. Unlike normal Go conventions, you should first check whether the call succeeded before checking the error result. For example: </p><pre>n, err := C.setenv(key, value, 1) if n != 0 { // we know the call failed, so it is now valid to use err return err } </pre><p>Calling C function pointers is currently not supported, however you can declare Go variables which hold C function pointers and pass them back and forth between Go and C. C code may call function pointers received from Go. For example: </p><pre>package main // typedef int (*intFunc) (); // // int // bridge_int_func(intFunc f) // { // return f(); // } // // int fortytwo() // { // return 42; // } import "C" import "fmt" func main() { f := C.intFunc(C.fortytwo) fmt.Println(int(C.bridge_int_func(f))) // Output: 42 } </pre><p>In C, a function argument written as a fixed size array actually requires a pointer to the first element of the array. C compilers are aware of this calling convention and adjust the call accordingly, but Go cannot. In Go, you must pass the pointer to the first element explicitly: C.f(&C.x[0]). </p><p>Calling variadic C functions is not supported. It is possible to circumvent this by using a C function wrapper. For example: </p><pre>package main // #include <stdio.h> // #include <stdlib.h> // // static void myprint(char* s) { // printf("%s\n", s); // } import "C" import "unsafe" func main() { cs := C.CString("Hello from stdio") C.myprint(cs) C.free(unsafe.Pointer(cs)) } </pre><p>A few special functions convert between Go and C types by making copies of the data. In pseudo-Go definitions: </p><pre>// Go string to C string // The C string is allocated in the C heap using malloc. // It is the caller's responsibility to arrange for it to be // freed, such as by calling C.free (be sure to include stdlib.h // if C.free is needed). func C.CString(string) *C.char // Go []byte slice to C array // The C array is allocated in the C heap using malloc. // It is the caller's responsibility to arrange for it to be // freed, such as by calling C.free (be sure to include stdlib.h // if C.free is needed). func C.CBytes([]byte) unsafe.Pointer // C string to Go string func C.GoString(*C.char) string // C data with explicit length to Go string func C.GoStringN(*C.char, C.int) string // C data with explicit length to Go []byte func C.GoBytes(unsafe.Pointer, C.int) []byte </pre><p>As a special case, C.malloc does not call the C library malloc directly but instead calls a Go helper function that wraps the C library malloc but guarantees never to return nil. If C's malloc indicates out of memory, the helper function crashes the program, like when Go itself runs out of memory. Because C.malloc cannot fail, it has no two-result form that returns errno. </p><h4 id="hdr-C_references_to_Go">C references to Go <a class="Documentation-idLink" href="#hdr-C_references_to_Go" title="Go to C references to Go" aria-label="Go to C references to Go">露</a></h4><p>Go functions can be exported for use by C code in the following way: </p><pre>//export MyFunction func MyFunction(arg1, arg2 int, arg3 string) int64 {...} //export MyFunction2 func MyFunction2(arg1, arg2 int, arg3 string) (int64, *C.char) {...} </pre><p>They will be available in the C code as: </p><pre>extern GoInt64 MyFunction(int arg1, int arg2, GoString arg3); extern struct MyFunction2_return MyFunction2(int arg1, int arg2, GoString arg3); </pre><p>found in the _cgo_export.h generated header, after any preambles copied from the cgo input files. Functions with multiple return values are mapped to functions returning a struct. </p><p>Not all Go types can be mapped to C types in a useful way. Go struct types are not supported; use a C struct type. Go array types are not supported; use a C pointer. </p><p>Go functions that take arguments of type string may be called with the C type _GoString_, described above. The _GoString_ type will be automatically defined in the preamble. Note that there is no way for C code to create a value of this type; this is only useful for passing string values from Go to C and back to Go. </p><p>Using //export in a file places a restriction on the preamble: since it is copied into two different C output files, it must not contain any definitions, only declarations. If a file contains both definitions and declarations, then the two output files will produce duplicate symbols and the linker will fail. To avoid this, definitions must be placed in preambles in other files, or in C source files. </p><h4 id="hdr-Passing_pointers">Passing pointers <a class="Documentation-idLink" href="#hdr-Passing_pointers" title="Go to Passing pointers" aria-label="Go to Passing pointers">露</a></h4><p>Go is a garbage collected language, and the garbage collector needs to know the location of every pointer to Go memory. Because of this, there are restrictions on passing pointers between Go and C. </p><p>In this section the term Go pointer means a pointer to memory allocated by Go (such as by using the & operator or calling the predefined new function) and the term C pointer means a pointer to memory allocated by C (such as by a call to C.malloc). Whether a pointer is a Go pointer or a C pointer is a dynamic property determined by how the memory was allocated; it has nothing to do with the type of the pointer. </p><p>Note that values of some Go types, other than the type's zero value, always include Go pointers. This is true of interface, channel, map, and function types. A pointer type may hold a Go pointer or a C pointer. Array, slice, string, and struct types may or may not include Go pointers, depending on their type and how they are constructed. All the discussion below about Go pointers applies not just to pointer types, but also to other types that include Go pointers. </p><p>All Go pointers passed to C must point to pinned Go memory. Go pointers passed as function arguments to C functions have the memory they point to implicitly pinned for the duration of the call. Go memory reachable from these function arguments must be pinned as long as the C code has access to it. Whether Go memory is pinned is a dynamic property of that memory region; it has nothing to do with the type of the pointer. </p><p>Go values created by calling new, by taking the address of a composite literal, or by taking the address of a local variable may also have their memory pinned using <a href="/runtime#Pinner">runtime.Pinner</a>. This type may be used to manage the duration of the memory's pinned status, potentially beyond the duration of a C function call. Memory may be pinned more than once and must be unpinned exactly the same number of times it has been pinned. </p><p>Go code may pass a Go pointer to C provided the memory to which it points does not contain any Go pointers to memory that is unpinned. When passing a pointer to a field in a struct, the Go memory in question is the memory occupied by the field, not the entire struct. When passing a pointer to an element in an array or slice, the Go memory in question is the entire array or the entire backing array of the slice. </p><p>C code may keep a copy of a Go pointer only as long as the memory it points to is pinned. </p><p>C code may not keep a copy of a Go pointer after the call returns, unless the memory it points to is pinned with <a href="/runtime#Pinner">runtime.Pinner</a> and the Pinner is not unpinned while the Go pointer is stored in C memory. This implies that C code may not keep a copy of a string, slice, channel, and so forth, because they cannot be pinned with <a href="/runtime#Pinner">runtime.Pinner</a>. </p><p>The _GoString_ type also may not be pinned with <a href="/runtime#Pinner">runtime.Pinner</a>. Because it includes a Go pointer, the memory it points to is only pinned for the duration of the call; _GoString_ values may not be retained by C code. </p><p>A Go function called by C code may return a Go pointer to pinned memory (which implies that it may not return a string, slice, channel, and so forth). A Go function called by C code may take C pointers as arguments, and it may store non-pointer data, C pointers, or Go pointers to pinned memory through those pointers. It may not store a Go pointer to unpinned memory in memory pointed to by a C pointer (which again, implies that it may not store a string, slice, channel, and so forth). A Go function called by C code may take a Go pointer but it must preserve the property that the Go memory to which it points (and the Go memory to which that memory points, and so on) is pinned. </p><p>These rules are checked dynamically at runtime. The checking is controlled by the cgocheck setting of the GODEBUG environment variable. The default setting is GODEBUG=cgocheck=1, which implements reasonably cheap dynamic checks. These checks may be disabled entirely using GODEBUG=cgocheck=0. Complete checking of pointer handling, at some cost in run time, is available by setting GOEXPERIMENT=cgocheck2 at build time. </p><p>It is possible to defeat this enforcement by using the unsafe package, and of course there is nothing stopping the C code from doing anything it likes. However, programs that break these rules are likely to fail in unexpected and unpredictable ways. </p><p>The runtime/cgo.Handle type can be used to safely pass Go values between Go and C. See the runtime/cgo package documentation for details. </p><p>Note: the current implementation has a bug. While Go code is permitted to write nil or a C pointer (but not a Go pointer) to C memory, the current implementation may sometimes cause a runtime error if the contents of the C memory appear to be a Go pointer. Therefore, avoid passing uninitialized C memory to Go code if the Go code is going to store pointer values in it. Zero out the memory in C before passing it to Go. </p><h4 id="hdr-Optimizing_calls_of_C_code">Optimizing calls of C code <a class="Documentation-idLink" href="#hdr-Optimizing_calls_of_C_code" title="Go to Optimizing calls of C code" aria-label="Go to Optimizing calls of C code">露</a></h4><p>When passing a Go pointer to a C function the compiler normally ensures that the Go object lives on the heap. If the C function does not keep a copy of the Go pointer, and never passes the Go pointer back to Go code, then this is unnecessary. The #cgo noescape directive may be used to tell the compiler that no Go pointers escape via the named C function. If the noescape directive is used and the C function does not handle the pointer safely, the program may crash or see memory corruption. </p><p>For example: </p><pre>// #cgo noescape cFunctionName </pre><p>When a Go function calls a C function, it prepares for the C function to call back to a Go function. The #cgo nocallback directive may be used to tell the compiler that these preparations are not necessary. If the nocallback directive is used and the C function does call back into Go code, the program will panic. </p><p>For example: </p><pre>// #cgo nocallback cFunctionName </pre><h4 id="hdr-Special_cases">Special cases <a class="Documentation-idLink" href="#hdr-Special_cases" title="Go to Special cases" aria-label="Go to Special cases">露</a></h4><p>A few special C types which would normally be represented by a pointer type in Go are instead represented by a uintptr. Those include: </p><p>1. The *Ref types on Darwin, rooted at CoreFoundation's CFTypeRef type. </p><p>2. The object types from Java's JNI interface: </p><pre>jobject jclass jthrowable jstring jarray jbooleanArray jbyteArray jcharArray jshortArray jintArray jlongArray jfloatArray jdoubleArray jobjectArray jweak </pre><p>3. The EGLDisplay and EGLConfig types from the EGL API. </p><p>These types are uintptr on the Go side because they would otherwise confuse the Go garbage collector; they are sometimes not really pointers but data structures encoded in a pointer type. All operations on these types must happen in C. The proper constant to initialize an empty such reference is 0, not nil. </p><p>These special cases were introduced in Go 1.10. For auto-updating code from Go 1.9 and earlier, use the cftype or jni rewrites in the Go fix tool: </p><pre>go tool fix -r cftype <pkg> go tool fix -r jni <pkg> </pre><p>It will replace nil with 0 in the appropriate places. </p><p>The EGLDisplay case was introduced in Go 1.12. Use the egl rewrite to auto-update code from Go 1.11 and earlier: </p><pre>go tool fix -r egl <pkg> </pre><p>The EGLConfig case was introduced in Go 1.15. Use the eglconf rewrite to auto-update code from Go 1.14 and earlier: </p><pre>go tool fix -r eglconf <pkg> </pre><h4 id="hdr-Using_cgo_directly">Using cgo directly <a class="Documentation-idLink" href="#hdr-Using_cgo_directly" title="Go to Using cgo directly" aria-label="Go to Using cgo directly">露</a></h4><p>Usage: </p><pre>go tool cgo [cgo options] [-- compiler options] gofiles... </pre><p>Cgo transforms the specified input Go source files into several output Go and C source files. </p><p>The compiler options are passed through uninterpreted when invoking the C compiler to compile the C parts of the package. </p><p>The following options are available when running cgo directly: </p><pre>-V Print cgo version and exit. -debug-define Debugging option. Print #defines. -debug-gcc Debugging option. Trace C compiler execution and output. -dynimport file Write list of symbols imported by file. Write to -dynout argument or to standard output. Used by go build when building a cgo package. -dynlinker Write dynamic linker as part of -dynimport output. -dynout file Write -dynimport output to file. -dynpackage package Set Go package for -dynimport output. -exportheader file If there are any exported functions, write the generated export declarations to file. C code can #include this to see the declarations. -gccgo Generate output for the gccgo compiler rather than the gc compiler. -gccgoprefix prefix The -fgo-prefix option to be used with gccgo. -gccgopkgpath path The -fgo-pkgpath option to be used with gccgo. -gccgo_define_cgoincomplete Define cgo.Incomplete locally rather than importing it from the "runtime/cgo" package. Used for old gccgo versions. -godefs Write out input file in Go syntax replacing C package names with real values. Used to generate files in the syscall package when bootstrapping a new target. -importpath string The import path for the Go package. Optional; used for nicer comments in the generated files. -import_runtime_cgo If set (which it is by default) import runtime/cgo in generated output. -import_syscall If set (which it is by default) import syscall in generated output. -ldflags flags Flags to pass to the C linker. The cmd/go tool uses this to pass in the flags in the CGO_LDFLAGS variable. -objdir directory Put all generated files in directory. -srcdir directory Find the Go input files, listed on the command line, in directory. -trimpath rewrites Apply trims and rewrites to source file paths. </pre> </section></div> </div> </div> <div class="UnitFiles js-unitFiles"> <h2 class="UnitFiles-title" id="section-sourcefiles"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/insert_drive_file_gm_grey_24dp.svg" alt=""> Source Files <a class="UnitFiles-idLink" href="#section-sourcefiles" title="Go to Source Files" aria-label="Go to Source Files">露</a> </h2> <div class="UnitFiles-titleLink"> <a href="https://cs.opensource.google/go/go/+/go1.24.2:src/cmd/cgo" target="_blank" rel="noopener">View all Source files</a> </div> <div> <ul class="UnitFiles-fileList"><li> <a href="https://cs.opensource.google/go/go/+/go1.24.2:src/cmd/cgo/ast.go" target="_blank" rel="noopener" title="ast.go">ast.go</a> </li><li> <a href="https://cs.opensource.google/go/go/+/go1.24.2:src/cmd/cgo/ast_go118.go" target="_blank" rel="noopener" title="ast_go118.go">ast_go118.go</a> </li><li> <a href="https://cs.opensource.google/go/go/+/go1.24.2:src/cmd/cgo/doc.go" target="_blank" rel="noopener" title="doc.go">doc.go</a> </li><li> <a href="https://cs.opensource.google/go/go/+/go1.24.2:src/cmd/cgo/gcc.go" target="_blank" rel="noopener" title="gcc.go">gcc.go</a> </li><li> <a href="https://cs.opensource.google/go/go/+/go1.24.2:src/cmd/cgo/godefs.go" target="_blank" rel="noopener" title="godefs.go">godefs.go</a> </li><li> <a href="https://cs.opensource.google/go/go/+/go1.24.2:src/cmd/cgo/main.go" target="_blank" rel="noopener" title="main.go">main.go</a> </li><li> <a href="https://cs.opensource.google/go/go/+/go1.24.2:src/cmd/cgo/out.go" target="_blank" rel="noopener" title="out.go">out.go</a> </li><li> <a href="https://cs.opensource.google/go/go/+/go1.24.2:src/cmd/cgo/util.go" target="_blank" rel="noopener" title="util.go">util.go</a> </li></ul> </div> </div> <div class="UnitDirectories js-unitDirectories"> <h2 class="UnitDirectories-title" id="section-directories"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/folder_gm_grey_24dp.svg" alt=""> Directories <a class="UnitDirectories-idLink" href="#section-directories" title="Go to Directories" aria-label="Go to Directories">露</a> </h2> <div class="UnitDirectories-toggles"> <div class="UnitDirectories-toggleButtons"> <button class="js-showInternalDirectories" data-test-id="internal-directories-toggle" data-gtmc="directories button" aria-label="Show Internal Directories"> Show internal </button> <button class="js-expandAllDirectories" data-test-id="directories-toggle" data-gtmc="directories button" aria-label="Expand All Directories"> Expand all </button> </div> </div> <table class="UnitDirectories-table UnitDirectories-table--tree js-expandableTable" data-test-id="UnitDirectories-table"> <tr class="UnitDirectories-tableHeader UnitDirectories-tableHeader--tree"> <th>Path</th> <th class="UnitDirectories-desktopSynopsis">Synopsis</th> </tr> <tr data-aria-controls="internal-cgotest internal-test internal-test/gcc68255 internal-test/issue23555a internal-test/issue23555b internal-test/issue24161arg internal-test/issue24161e0 internal-test/issue24161e1 internal-test/issue24161e2 internal-test/issue24161res internal-test/issue26213 internal-test/issue26430 internal-test/issue26743 internal-test/issue27054 internal-test/issue27340 internal-test/issue29563 internal-test/issue30527 internal-test/issue41761a internal-test/issue43639 internal-test/issue52611a internal-test/issue52611b internal-test/issue8756 internal-test/issue8828 internal-test/issue9026 internal-test/issue9400 internal-test/issue9510a internal-test/issue9510b internal-testnocgo internal-testtls " class="UnitDirectories-internal"> <td data-id="internal" data-aria-owns="internal-cgotest internal-test internal-test/gcc68255 internal-test/issue23555a internal-test/issue23555b internal-test/issue24161arg internal-test/issue24161e0 internal-test/issue24161e1 internal-test/issue24161e2 internal-test/issue24161res internal-test/issue26213 internal-test/issue26430 internal-test/issue26743 internal-test/issue27054 internal-test/issue27340 internal-test/issue29563 internal-test/issue30527 internal-test/issue41761a internal-test/issue43639 internal-test/issue52611a internal-test/issue52611b internal-test/issue8756 internal-test/issue8828 internal-test/issue9026 internal-test/issue9400 internal-test/issue9510a internal-test/issue9510b internal-testnocgo internal-testtls "> <div class="UnitDirectories-pathCell"> <div><button type="button" class="go-Button go-Button--inline UnitDirectories-toggleButton" aria-expanded="false" aria-label="29 more from" data-aria-controls="internal-cgotest internal-test internal-test/gcc68255 internal-test/issue23555a internal-test/issue23555b internal-test/issue24161arg internal-test/issue24161e0 internal-test/issue24161e1 internal-test/issue24161e2 internal-test/issue24161res internal-test/issue26213 internal-test/issue26430 internal-test/issue26743 internal-test/issue27054 internal-test/issue27340 internal-test/issue29563 internal-test/issue30527 internal-test/issue41761a internal-test/issue43639 internal-test/issue52611a internal-test/issue52611b internal-test/issue8756 internal-test/issue8828 internal-test/issue9026 internal-test/issue9400 internal-test/issue9510a internal-test/issue9510b internal-testnocgo internal-testtls " data-aria-labelledby="internal-button internal" data-id="internal-button"> <img class="go-Icon" height="24" width="24" src="/static/shared/icon/arrow_right_gm_grey_24dp.svg" alt=""> </button><span>internal</span> </td> <td class="UnitDirectories-desktopSynopsis"></td></tr><tr data-id="internal-cgotest" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/cgotest@go1.24.2">cgotest</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test@go1.24.2">test</a> </span> <div class="UnitDirectories-mobileSynopsis">Test that pthread_cancel works as expected (NPTL uses SIGRTMIN to implement thread cancellation) See https://golang.org/issue/6997</div> </div> </td> <td class="UnitDirectories-desktopSynopsis">Test that pthread_cancel works as expected (NPTL uses SIGRTMIN to implement thread cancellation) See https://golang.org/issue/6997</td><tr data-id="internal-test/gcc68255" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/gcc68255@go1.24.2">test/gcc68255</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue23555a" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue23555a@go1.24.2">test/issue23555a</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue23555b" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue23555b@go1.24.2">test/issue23555b</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue24161arg" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue24161arg@go1.24.2">test/issue24161arg</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue24161e0" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue24161e0@go1.24.2">test/issue24161e0</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue24161e1" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue24161e1@go1.24.2">test/issue24161e1</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue24161e2" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue24161e2@go1.24.2">test/issue24161e2</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue24161res" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue24161res@go1.24.2">test/issue24161res</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue26213" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue26213@go1.24.2">test/issue26213</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue26430" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue26430@go1.24.2">test/issue26430</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue26743" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue26743@go1.24.2">test/issue26743</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue27054" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue27054@go1.24.2">test/issue27054</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue27340" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue27340@go1.24.2">test/issue27340</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue29563" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue29563@go1.24.2">test/issue29563</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue30527" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue30527@go1.24.2">test/issue30527</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue41761a" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue41761a@go1.24.2">test/issue41761a</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue43639" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue43639@go1.24.2">test/issue43639</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue52611a" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue52611a@go1.24.2">test/issue52611a</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue52611b" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue52611b@go1.24.2">test/issue52611b</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue8756" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue8756@go1.24.2">test/issue8756</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue8828" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue8828@go1.24.2">test/issue8828</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue9026" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue9026@go1.24.2">test/issue9026</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue9400" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue9400@go1.24.2">test/issue9400</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue9510a" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue9510a@go1.24.2">test/issue9510a</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-test/issue9510b" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/test/issue9510b@go1.24.2">test/issue9510b</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-testnocgo" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/testnocgo@go1.24.2">testnocgo</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td><tr data-id="internal-testtls" class="UnitDirectories-internal"> <td> <div class="UnitDirectories-subdirectory"> <span> <a href="/cmd/cgo/internal/testtls@go1.24.2">testtls</a> </span> <div class="UnitDirectories-mobileSynopsis"></div> </div> </td> <td class="UnitDirectories-desktopSynopsis"></td></tr> </table> </div> </div> </div> <div id="showInternal-description" hidden> Click to show internal directories. </div> <div id="hideInternal-description" hidden> Click to hide internal directories. </div> </article> <footer class="go-Main-footer"></footer> </main> <footer class="go-Footer"> <div class="go-Footer-links"> <div class="go-Footer-linkColumn"> <a href="https://go.dev/solutions" class="go-Footer-link go-Footer-link--primary" data-gtmc="footer link"> Why Go </a> <a href="https://go.dev/solutions#use-cases" class="go-Footer-link" data-gtmc="footer link"> Use Cases </a> <a href="https://go.dev/solutions#case-studies" class="go-Footer-link" data-gtmc="footer link"> Case Studies </a> </div> <div class="go-Footer-linkColumn"> <a href="https://learn.go.dev/" class="go-Footer-link go-Footer-link--primary" data-gtmc="footer link"> Get Started </a> <a href="https://play.golang.org" class="go-Footer-link" data-gtmc="footer link"> Playground </a> <a href="https://tour.golang.org" class="go-Footer-link" data-gtmc="footer link"> Tour </a> <a href="https://stackoverflow.com/questions/tagged/go?tab=Newest" class="go-Footer-link" data-gtmc="footer link"> Stack Overflow </a> <a href="https://go.dev/help" class="go-Footer-link" data-gtmc="footer link"> Help </a> </div> <div class="go-Footer-linkColumn"> <a href="https://pkg.go.dev" class="go-Footer-link go-Footer-link--primary" data-gtmc="footer link"> Packages </a> <a href="/std" class="go-Footer-link" data-gtmc="footer link"> Standard Library </a> <a href="/golang.org/x" class="go-Footer-link" data-gtmc="footer link"> Sub-repositories </a> <a href="https://pkg.go.dev/about" class="go-Footer-link" data-gtmc="footer link"> About Go Packages </a> </div> <div class="go-Footer-linkColumn"> <a href="https://go.dev/project" class="go-Footer-link go-Footer-link--primary" data-gtmc="footer link"> About </a> <a href="https://go.dev/dl/" class="go-Footer-link" data-gtmc="footer link">Download</a> <a href="https://go.dev/blog" class="go-Footer-link" data-gtmc="footer link">Blog</a> <a href="https://github.com/golang/go/issues" class="go-Footer-link" data-gtmc="footer link"> Issue Tracker </a> <a href="https://go.dev/doc/devel/release.html" class="go-Footer-link" data-gtmc="footer link"> Release Notes </a> <a href="https://blog.golang.org/go-brand" class="go-Footer-link" data-gtmc="footer link"> Brand Guidelines </a> <a href="https://go.dev/conduct" class="go-Footer-link" data-gtmc="footer link"> Code of Conduct </a> </div> <div class="go-Footer-linkColumn"> <a href="https://www.twitter.com/golang" class="go-Footer-link go-Footer-link--primary" data-gtmc="footer link"> Connect </a> <a href="https://www.twitter.com/golang" class="go-Footer-link" data-gtmc="footer link"> Twitter </a> <a href="https://github.com/golang" class="go-Footer-link" data-gtmc="footer link">GitHub</a> <a href="https://invite.slack.golangbridge.org/" class="go-Footer-link" data-gtmc="footer link"> Slack </a> <a href="https://reddit.com/r/golang" class="go-Footer-link" data-gtmc="footer link"> r/golang </a> <a href="https://www.meetup.com/pro/go" class="go-Footer-link" data-gtmc="footer link"> Meetup </a> <a href="https://golangweekly.com/" class="go-Footer-link" data-gtmc="footer link"> Golang Weekly </a> </div> </div> <div class="go-Footer-bottom"> <img class="go-Footer-gopher" width="1431" height="901" src="/static/shared/gopher/pilot-bust-1431x901.svg" alt="Gopher in flight goggles"> <ul class="go-Footer-listRow"> <li class="go-Footer-listItem"> <a href="https://go.dev/copyright" data-gtmc="footer link">Copyright</a> </li> <li class="go-Footer-listItem"> <a href="https://go.dev/tos" data-gtmc="footer link">Terms of Service</a> </li> <li class="go-Footer-listItem"> <a href="http://www.google.com/intl/en/policies/privacy/" data-gtmc="footer link" target="_blank" rel="noopener"> Privacy Policy </a> </li> <li class="go-Footer-listItem"> <a href="https://go.dev/s/pkgsite-feedback" target="_blank" rel="noopener" data-gtmc="footer link"> Report an Issue </a> </li> <li class="go-Footer-listItem"> <button class="go-Button go-Button--text go-Footer-toggleTheme js-toggleTheme" aria-label="Theme Toggle"> <img data-value="auto" class="go-Icon go-Icon--inverted" height="24" width="24" src="/static/shared/icon/brightness_6_gm_grey_24dp.svg" alt="System theme"> <img data-value="dark" class="go-Icon go-Icon--inverted" height="24" width="24" src="/static/shared/icon/brightness_2_gm_grey_24dp.svg" alt="Dark theme"> <img data-value="light" class="go-Icon go-Icon--inverted" height="24" width="24" src="/static/shared/icon/light_mode_gm_grey_24dp.svg" alt="Light theme"> <p> Theme Toggle </p> </button> </li> <li class="go-Footer-listItem"> <button class="go-Button go-Button--text go-Footer-keyboard js-openShortcuts" aria-label="Shorcuts Modal"> <img class="go-Icon go-Icon--inverted" height="24" width="24" src="/static/shared/icon/keyboard_grey_24dp.svg" alt=""> <p> Shortcuts Modal </p> </button> </li> </ul> <a class="go-Footer-googleLogo" href="https://google.com" target="_blank"rel="noopener" data-gtmc="footer link"> <img class="go-Footer-googleLogoImg" height="24" width="72" src="/static/shared/logo/google-white.svg" alt="Google logo"> </a> </div> </footer> <dialog id="jump-to-modal" class="JumpDialog go-Modal go-Modal--md js-modal"> <form method="dialog" data-gmtc="jump to form" aria-label="Jump to Identifier"> <div class="Dialog-title go-Modal-header"> <h2>Jump to</h2> <button class="go-Button go-Button--inline" type="button" data-modal-close data-gtmc="modal button" aria-label="Close" > <img class="go-Icon" height="24" width="24" src="/static/shared/icon/close_gm_grey_24dp.svg" alt="" /> </button> </div> <div class="JumpDialog-filter"> <input class="JumpDialog-input go-Input" autocomplete="off" type="text"> </div> <div class="JumpDialog-body go-Modal-body"> <div class="JumpDialog-list"></div> </div> <div class="go-Modal-actions"> <button class="go-Button" data-test-id="close-dialog">Close</button> </div> </form> </dialog> <dialog class="ShortcutsDialog go-Modal go-Modal--sm js-modal"> <form method="dialog"> <div class="go-Modal-header"> <h2>Keyboard shortcuts</h2> <button class="go-Button go-Button--inline" type="button" data-modal-close data-gtmc="modal button" aria-label="Close" > <img class="go-Icon" height="24" width="24" src="/static/shared/icon/close_gm_grey_24dp.svg" alt="" /> </button> </div> <div class="go-Modal-body"> <table> <tbody> <tr><td class="ShortcutsDialog-key"> <strong>?</strong></td><td> : This menu</td> </tr> <tr><td class="ShortcutsDialog-key"> <strong>/</strong></td><td> : Search site</td> </tr> <tr><td class="ShortcutsDialog-key"> <strong>f</strong> or <strong>F</strong></td><td> : Jump to</td> </tr> <tr> <td class="ShortcutsDialog-key"><strong>y</strong> or <strong>Y</strong></td> <td> : Canonical URL</td> </tr> </tbody> </table> </div> <div class="go-Modal-actions"> <button class="go-Button" data-test-id="close-dialog">Close</button> </div> </form> </dialog> <section class="Cookie-notice js-cookieNotice"> <div>go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic. <a target=_blank href="https://policies.google.com/technologies/cookies">Learn more.</a></div> <div><button class="go-Button">Okay</button></div> </section> <script> // this will throw if the querySelector can鈥檛 find the element const gtmId = document.querySelector('.js-gtmID').dataset.gtmid; if (!gtmId) { throw new Error('Google Tag Manager ID not found'); } loadScript(`https://www.googletagmanager.com/gtm.js?id=${gtmId}`); </script> <noscript> <iframe src="https://www.googletagmanager.com/ns.html?id=GTM-W8MVQXG" height="0" width="0" style="display:none;visibility:hidden"> </iframe> </noscript> <div class="js-canonicalURLPath" data-canonical-url-path="/cmd/cgo@go1.24.2" hidden></div> <div class="js-playgroundVars" data-modulepath="std" data-version="v1.24.2" hidden></div> <script> loadScript('/static/frontend/unit/main/main.js') </script> <script> loadScript('/static/frontend/unit/unit.js') </script> </body> </html>