structdef

package
v0.0.0-...-9c8aaae Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Copyright © 2019 hori-ryota <hori.ryota@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

View Source
var StructDefTemplate = template.Must(template.New("").Funcs(map[string]interface{}{
	"ToLowerCamel": strcase.ToLowerCamel,
	"ToUpperCamel": strcase.ToUpperCamel,
	"PrintDefs":    printDefs,
}).Parse(strings.TrimSpace(`
// Code generated by go-codegen api protobuf kotlin_client httprpc structdef; DO NOT EDIT

package {{.KotlinPackage}}

import kotlinx.serialization.SerialId
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
{{ PrintDefs .TypeDefs}}
`)))

Functions

func AddIndent

func AddIndent(s string, indent int) string

func Generate

func Generate(
	usecasePkgInfo *loader.PackageInfo,
	kotlinPackage string,
) (string, error)

func IsKnownNamedType

func IsKnownNamedType(t *types.Named) bool

func KnownTypesToKotlinType

func KnownTypesToKotlinType(t types.Type) (string, bool)

func NewStructdefCmd

func NewStructdefCmd() *cobra.Command

func Run

func Run(
	usecaseDir string,
	outputDir string,
	kotlinPackage string,
	useStdOut bool,
) error

Types

type EnumDef

type EnumDef struct {
	Type   *types.Named
	Values []*types.Const
}

type RPC

type RPC struct {
	InputType  *types.Named
	OutputType *types.Named
}

func ParseRPC

func ParseRPC(method *types.Func) (*RPC, error)

type TemplateParam

type TemplateParam struct {
	KotlinPackage string
	TypeDefs      []*types.Named
}

Jump to

Keyboard shortcuts

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