Install
You need three things: Go, a browser that speaks the Chrome DevTools Protocol, and the chromedp module.
chromedp needs Go 1.25 or later. Get Go from go.dev/dl, then check the version:
go versionA browser
Section titled “A browser”chromedp starts Chrome or Chromium on the computer that runs the program. It looks for the browser in these places, in order:
- On Linux and the other Unix systems:
headless-shell,chromium,google-chromeand the other names of Chrome on thePATH. - On macOS: Chromium, then Google Chrome, in
/Applications. - On Windows: Chrome on the
PATHand in its usual folders, then Microsoft Edge, which is built on Chromium.
To use another browser, give its path with the option chromedp.ExecPath.
See Contexts and the browser.
A server with no Chrome can run the container image chromedp/headless-shell, which holds a small build of Chrome. See Connect to a browser.
The module
Section titled “The module”Make a module for your program, and add chromedp to it:
mkdir hello && cd hellogo mod init example.com/hellogo get github.com/chromedp/chromedp@latestThe packages of the protocol, such as page and network, are in the module
github.com/chromedp/cdproto. go get adds it with chromedp.
Next, write your first program.