typeString

package
v0.0.0-...-afccd23 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: GPL-2.0 Imports: 0 Imported by: 0

README

对于其他类型,只要实现了String方法,就可以定义该类型的字符串表示形式。

package main

import "fmt"

func main() {
	studentInfo := student{
		Name: "张三",
		Age:  1,
	}
	fmt.Println(studentInfo)
}

type student struct {
	Name string
	Age  int64
}

func (s student) String() string {
	return fmt.Sprintf("我是%s, 今年%d岁", s.Name, s.Age)
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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