Skip to content

gohugoio/hugoreleaser-plugins-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tests on Linux, MacOS and Windows Go Report Card GoDoc

Plugins API for https://github.com/gohugoio/hugoreleaser

A plugin is a Go Module with a main func, e.g., using the API provided by the archiveplugin package:

func main() {
	server, err := server.New(
		func(d server.Dispatcher, req archiveplugin.Request) archiveplugin.Response {
			d.Infof("Creating archive %s", req.OutFilename)

			if err := req.Init(); err != nil {
				// ... handle error.
			}

			if err := createArchive(req); err != nil {
				// ... handle error.
			}
			// Empty response is a success.
			return archiveplugin.Response{}
		},
	)
	if err != nil {
		log.Fatalf("Failed to create server: %s", err)
	}

	if err := server.Start(); err != nil {
		log.Fatalf("Failed to start server: %s", err)
	}

	_ = server.Wait()
}

See the Deb Plugin for a more complete example.