Skip to content
Go Windows Service wrapper that plays nice with Linux.
Go Shell Batchfile
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
example ci: updates for static analysis tools Jan 4, 2019
svc test: fix windows test imports Jan 4, 2019
.gitignore update .gitignore Feb 5, 2017
LICENSE Initial commit Feb 19, 2016 Update Apr 18, 2016
empty.go build: add empty go file for dep install (#7) Jan 21, 2019


GoDoc MIT License Go Report Card Build Status

Go Windows Service wrapper that plays nice with Linux. Windows tests here.

Project Status

  • Used in Production.
  • Maintained. Issues and Pull Requests will be responded to.


go get -u


package main

import (


// program implements svc.Service
type program struct {
	wg   sync.WaitGroup
	quit chan struct{}

func main() {
	prg := &program{}

	// Call svc.Run to start your program/service.
	if err := svc.Run(prg); err != nil {

func (p *program) Init(env svc.Environment) error {
	log.Printf("is win service? %v\n", env.IsWindowsService())
	return nil

func (p *program) Start() error {
	// The Start method must not block, or Windows may assume your service failed
	// to start. Launch a Goroutine here to do something interesting/blocking.

	p.quit = make(chan struct{})

	go func() {
		log.Println("Quit signal received...")

	return nil

func (p *program) Stop() error {
	// The Stop method is invoked by stopping the Windows service, or by pressing Ctrl+C on the console.
	// This method may block, but it's a good idea to finish quickly or your process may be killed by
	// Windows during a shutdown/reboot. As a general rule you shouldn't rely on graceful shutdown.

	return nil

More Examples

See the example directory for more examples, including installing and uninstalling binaries built in Go as Windows services.

Similar Projects


go-svc is under the MIT license. See the LICENSE file for details.

You can’t perform that action at this time.