annotations

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package annotations finds and parses annotations in the comments to an interface or method. An annotation must have the following format: @Name{"key1":"value1", "key2": "value2", ...}, i.e. it begins with an @ characater, followed by a name followed by a valid json object.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseInterfaceAnnotations

func ParseInterfaceAnnotations(i parse.Interface) (map[string]InterfaceAnnotation, error)

Returns a map of annotations found in the comments of the given interface. The map keys are the annotation names and the values are instances of InterfaceAnnotation.

func ParseJSONAnnotation

func ParseJSONAnnotation(annotation string, result interface{}) error

Parses the annotation as JSON and stores the result in the "result" parameter, which should usually be a pointer to a struct or map.

Types

type InterfaceAnnotation

type InterfaceAnnotation struct {
	// Name of the annotation
	Name string
	// The annotation on the interface
	Annotation string
	// Annotations on the interface methods.
	// Slice has the same length as parse.Interface.Methods.
	// Contain empty string for methods without an annotation.
	MethodAnnotations []string
}

An annotation on an interface.

Jump to

Keyboard shortcuts

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