This commit is contained in:
teivah 2022-02-04 21:54:30 +01:00
parent 4e9a04064a
commit f3f5d06bcf
No known key found for this signature in database
GPG key ID: 07E4A13FB8F8DF63
6 changed files with 17 additions and 15 deletions

View file

@ -1,6 +1,6 @@
package store
type Storer interface {
type CustomerStorage interface {
StoreCustomer(customer Customer) error
GetCustomer(id string) (Customer, error)
UpdateCustomer(customer Customer) error

View file

@ -5,6 +5,12 @@ import "fmt"
func main() {
var n float32 = 1.0001
fmt.Println(n * n)
var a float64
positiveInf := 1 / a
negativeInf := -1 / a
nan := a / a
fmt.Println(positiveInf, negativeInf, nan)
}
func f1(n int) float64 {

View file

@ -12,9 +12,7 @@ func main() {
s = append(s, 2)
print(s)
s = append(s, 3)
s = append(s, 4)
s = append(s, 5)
s = append(s, 3, 4, 5)
print(s)
s1 := make([]int, 3, 6)

View file

@ -17,6 +17,9 @@ func main() {
for i, r := range runes {
fmt.Printf("position %d: %c\n", i, r)
}
s2 := "hello"
fmt.Printf("%c\n", rune(s2[4]))
}
func getIthRune(largeString string, i int) rune {

View file

@ -1,5 +1,7 @@
package main
import "io"
func f(a int) (b int) {
b = a
return
@ -16,7 +18,7 @@ func (l loc) getCoordinates(address string) (lat, lng float32, err error) {
return 0, 0, nil
}
func ReadFull(r Reader, buf []byte) (n int, err error) {
func ReadFull(r io.Reader, buf []byte) (n int, err error) {
for len(buf) > 0 && err == nil {
var nr int
nr, err = r.Read(buf)
@ -25,9 +27,3 @@ func ReadFull(r Reader, buf []byte) (n int, err error) {
}
return
}
type Reader struct{}
func (Reader) Read([]byte) (int, error) {
return 0, nil
}

View file

@ -14,7 +14,7 @@ func (t transientError) Error() string {
return fmt.Sprintf("transient error: %v", t.err)
}
func GetTransactionAmountHandler(w http.ResponseWriter, r *http.Request) {
func handler(w http.ResponseWriter, r *http.Request) {
transactionID := r.URL.Query().Get("transaction")
amount, err := getTransactionAmount1(transactionID)
@ -48,13 +48,12 @@ func getTransactionAmountFromDB1(id string) (float32, error) {
return 0, nil
}
func GetTransactionAmount2(w http.ResponseWriter, r *http.Request) {
func handler2(w http.ResponseWriter, r *http.Request) {
transactionID := r.URL.Query().Get("transaction")
amount, err := getTransactionAmount2(transactionID)
if err != nil {
terr := transientError{}
if errors.As(err, &terr) {
if errors.As(err, &transientError{}) {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
} else {
http.Error(w, err.Error(), http.StatusBadRequest)