demo

package
v0.5.15 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(a, b int) int

Add 两个整数相加

func Calculate

func Calculate(a, b int) int

Calculate 计算两个整数之和

func Divide

func Divide(a, b int) (int, error)

Divide 两个数相除,除数为0时返回错误

func Drain

func Drain(ch <-chan int) []int

通道操作

func Max

func Max[T int | int64 | float64](a, b T) T

泛型函数

func Subtract

func Subtract(a, b int) int

Subtract 两个整数相减

func SumAll

func SumAll(prefix string, nums ...int) (string, int)

变参函数

Types

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

带结构体字段的方法

func (*Stack) Pop

func (s *Stack) Pop() (int, bool)

func (*Stack) Push

func (s *Stack) Push(item int)

type Stringer

type Stringer interface {
	String() string
}

接口定义

type User

type User struct {
	ID    int
	Name  string
	Email string
}

User 用户结构体

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

UserService 用户服务

func NewUserService

func NewUserService() *UserService

NewUserService 创建用户服务

func (*UserService) AddUser

func (s *UserService) AddUser(user User) error

AddUser 添加用户

func (*UserService) GetUser

func (s *UserService) GetUser(id int) (User, error)

GetUser 获取用户

Jump to

Keyboard shortcuts

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