file

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package file provides types that represent a repository interface and it's methods, as well as go types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	// Len is the length of the array.
	//
	// A negative value indicates that this is a slice.
	Len int64

	Elem Type
}

Array is a Type representing arrays and slices.

func (Array) String

func (t Array) String() string

type Func added in v0.1.3

type Func struct {
	Params  []Type
	Results []Type
}

func (Func) String added in v0.1.3

func (f Func) String() string

type ImportManager

type ImportManager struct {
	// Imports is a map of import names to their paths, used to prevent
	// collisions.
	Imports map[string]string // map[importName]importPath
}

ImportManager is a helper used to manager conflicting imports.

func NewImportManager

func NewImportManager() *ImportManager

func (*ImportManager) Add

func (m *ImportManager) Add(path string) string

type Map

type Map struct {
	Key, Value Type
}

func (Map) String

func (t Map) String() string

type Method

type Method struct {
	// Name is the name of the file.
	Name    string
	Params  []Param
	Returns []Return
}

func NewMethod

func NewMethod(f *types.Func, im *ImportManager) (*Method, error)

type Named

type Named struct {
	// Package is the name of the package this type belongs to, if any.
	//
	// If an import alias was used, Package will be the alias.
	Package string
	// PackagePath is the import path of the package of the type.
	PackagePath string

	// Name is the name of the type.
	Name string
}

Named is a Type representing all named types, such as structs, interfaces, or primitives.

func (Named) String

func (t Named) String() string

type Param

type Param struct {
	// Name is the name of the parameter.
	//
	// If the parameter was not named in the interface definition, Name
	// will be generated by dblog.
	Name string
	// GeneratedName indicates whether Name was generated by dblog.
	GeneratedName bool
	// Type is the type of the parameter.
	Type Type
	// Variadic indicates whether the parameter is variadic.
	//
	// This can only be true for the last parameter.
	//
	// If true, Type will be of type Array.
	Variadic bool
}

func NewParam

func NewParam(name string, v *types.Var, im *ImportManager) (*Param, error)

type Pointer

type Pointer struct {
	Elem Type
}

func (Pointer) String

func (p Pointer) String() string

type Return

type Return struct {
	// Name is the name of the return value and is also used as the name of
	// the variable that holds this return value.
	//
	// If the return value was not named in the interface definition, Name
	// will be generated by dblog.
	Name string
	// GeneratedName indicates whether Name was generated by dblog.
	GeneratedName bool
	// Type is the type of the return value.
	Type Type
}

func NewReturn

func NewReturn(name string, v *types.Var, im *ImportManager) (*Return, error)

type Type

type Type interface {
	String() string
	// contains filtered or unexported methods
}

func NewType

func NewType(t types.Type, m *ImportManager) (Type, error)

Jump to

Keyboard shortcuts

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