Running chrome with command line parameters

I am using systray and open to open chrome browser on a url (mostly served by the golang server itself…), e.g.:

func main() {
	fmt.Println("Quando Go Server started")
	go server.ServeHTTPandIO(handlers)
	systray.Run(onReady, nil)

func onReady() {
	systray.SetTooltip("Quando - noCode Toolset")
	sysEditor := systray.AddMenuItem("Editor", "Open Editor")
	sysClient := systray.AddMenuItem("Client", "Open Client")
	sysDashboard := systray.AddMenuItem("Dashboard", "Open Dashboard")
	sysGithub := systray.AddMenuItem("Quando:Github", "Open Quando -> Github")
	sysQuit := systray.AddMenuItem("Quit", "Stop the server")
	go func() {
		for {
			select {
			case <-sysQuit.ClickedCh:
			case <-sysEditor.ClickedCh:
				open.StartWith("", "chrome")
			case <-sysClient.ClickedCh:
				open.StartWith("", "chrome")
			case <-sysDashboard.ClickedCh:
				open.StartWith("", "chrome")
			case <-sysGithub.ClickedCh:

However, there doesn’t seem to be any way to pass in command line parameters - I would like to pass in ‘–allow-insecure-localhost’.

Does anyone know of a (cross platform) package/option similar to open-lang open that allows specifying the application as chrome AND passing parameters :slight_smile:

Note: I know that lorca does this - but also provides much more than I need…I am considering stripping ‘LocateChrome’ from lorca and using that…

Thank you in advance - Andy

@Andrew_Stratton I suggest you use the os/exec library. You can do something like this:

package main

import (

func main() {
    output, err := exec.Command("chrome", "--allow-insecure-localhost").Output()
    if err != nil {


Thank you Brandon

I have just been down that route myself - but using lorca to find chrome, since chrome isn’t in PATH by default in windows (and I need very easy deployment/setup). i.e.

	loc := lorca.LocateChrome()
	cmd := exec.Command(loc, "--new-window", "--allow-insecure-localhost", ""+suffix)
	err := cmd.Run()
	if err != nil {

This partly works - i.e. opens a new window - but it doesn’t enable insecure localhost when chrome is already running, since it reuses the existing application.

I think I will have to consider using a profile - so this becomes a chrome specific issue…

Thank you - Andy

Using user-data-dir allows a different profile so that a new instance of chrome is run, e.g. (for windows) changing the previous example to include:

	cmd := exec.Command(loc, "--new-window", "--user-data-dir=C:\\chrome_dir", "--allow-insecure-localhost", ""+suffix)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.