push all exercices

This commit is contained in:
lbenedar
2026-02-21 14:09:13 +03:00
commit a94d994b8c
72 changed files with 787 additions and 0 deletions

BIN
ch9/1/ch9_1.exe Normal file

Binary file not shown.

33
ch9/1/ch9_1.go Normal file
View File

@@ -0,0 +1,33 @@
package main
import (
"errors"
"fmt"
)
type SentinelError string
func (s SentinelError) Error() string {
return string(s)
}
func (s SentinelError) Is(target error) bool {
return s.Error() == target.Error()
}
const (
ErrId = SentinelError("Wrong ID")
ErrTest = SentinelError("Wrong Test")
)
func main() {
errId := ErrId
errTest := ErrTest
fmt.Printf("Does ErrId found: %b\n", errors.Is(errId, ErrId))
fmt.Printf("Does ErrTest found: %b\n", errors.Is(errId, ErrTest))
fmt.Printf("Does ErrId found: %b\n", errors.Is(errTest, ErrId))
fmt.Printf("Does ErrTest found: %b\n", errors.Is(errTest, ErrTest))
}

3
ch9/1/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module ch9_1
go 1.25.0