shared-sqs: Этап 1 — клон GoAWS, удаление SNS, go build OK

This commit is contained in:
Naeel
2026-04-09 12:25:02 +03:00
parent d1d1bffd7c
commit f4352a17b1
58 changed files with 9688 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
package models
import (
"encoding/json"
"strconv"
)
// StringToInt this is a custom type that will allow our request bodies to support either a string OR an int.
// It has its own UnmarshalJSON method to handle both types automatically and it can return an `int`
// from the `Int` method.
type StringToInt int
func (s *StringToInt) UnmarshalJSON(data []byte) error {
var i int
err := json.Unmarshal(data, &i)
if err == nil {
*s = StringToInt(i)
return nil
}
var str string
err = json.Unmarshal(data, &str)
if err != nil {
return err
}
tmp, err := strconv.Atoi(str)
if err != nil {
return err
}
*s = StringToInt(tmp)
return nil
}
func (s *StringToInt) Int() int {
return int(*s)
}