docs

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2020 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package docs holds go code for inclusion into the prose documentation.

The documentation is available online at https://quay.github.io/claircore/

Example (Logger)

Example_logger is an example annotated for inclusion in the prose documentation.

package main

import (
	"context"
	"time"

	"github.com/rs/zerolog"
)

func main() {
	ctx := context.Background()
	// ANCHOR: logger
	log := zerolog.Ctx(ctx).With().
		// ANCHOR_END: logger
		// ANCHOR: kvs
		Str("component", "Example.Logger").
		// ANCHOR_END: kvs
		// ANCHOR: newlogger
		Logger()
		// ANCHOR_END: newlogger
	// ANCHOR: context
	ctx = log.WithContext(ctx)
	// ANCHOR_END: context

	// ANCHOR: bad_example
	log.Info().Msgf("done at: %v", time.Now())
	// ANCHOR_END: bad_example
	// ANCHOR: good_example
	log.Info().
		Time("time", time.Now()).
		Msgf("done")
	// ANCHOR_END: good_example
}
Output:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL