Skip to content

Instantly share code, notes, and snippets.

Last active Apr 18, 2019
What would you like to do?
Electron-like html+golang app
<title>Hello, from Go</title>
This is Go code running, {{.}}
// Copyright 2016 Google Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// Unless required by applicable law or agreed to writing, software distributed
// under the License is distributed on a "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
const (
listen = "localhost:2016"
chrome = "/Applications/Google Chrome"
func main() {
http.HandleFunc("/", handler)
errc := make(chan error)
go func() { errc <- http.ListenAndServe(listen, nil) }()
if err := exec.Command(chrome, "--app=http://"+listen).Run(); err != nil {
var tmpl = template.Must(template.ParseFiles("home.tmpl"))
func handler(w http.ResponseWriter, r *http.Request) {
if err := tmpl.Execute(w, os.Getenv("USER")); err != nil {
log.Printf("could not render home: %v", err)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment