package main import ( "fmt" "strings" ) type battery uint8 func (b *battery) set(str string) { *b = battery(strings.Count(str, `1`)) } func (b battery) String() string { return fmt.Sprintf("[%10s]", strings.Repeat("X", int(b))) } func main() { var batteryForTest battery var str string fmt.Scan(&str) batteryForTest.set(str) fmt.Println(batteryForTest) }