package main

import (
	"fmt"
	"slices"
	"unicode/utf8"
	"unsafe"
)

type problem struct{}

func (*problem) Error() string { return "problem" }
func main() {
	base := []int{1, 2, 3, 4}
	shared := append(base[:2], 9)
	detached := append(base[:2:2], 8)
	fmt.Println("slice:", base, shared, detached)
	cloned := slices.Clone(base)
	cloned[0] = 7
	fmt.Println("clone:", base, cloned)
	m := map[string]int{"x": 1}
	alias := m
	alias["x"] = 2
	v, ok := m["missing"]
	fmt.Println("map:", m["x"], v, ok)
	ch := make(chan int, 1)
	ch <- 7
	close(ch)
	v, ok = <-ch
	fmt.Println("channel:", v, ok)
	v, ok = <-ch
	fmt.Println("channel:", v, ok)
	var p *problem
	var err error = p
	fmt.Println("nil:", p == nil, err == nil)
	s := "中A"
	b := []byte(s)
	b[0] = 'X'
	fmt.Println("string:", len(s), utf8.RuneCountInString(s), s)
	fmt.Println("value sizes:", unsafe.Sizeof(base), unsafe.Sizeof(m), unsafe.Sizeof(ch), unsafe.Sizeof(err), unsafe.Sizeof(s))
}
