64 ),
65 )
66 if err != nil {
67 log.Fatal(err) 68 }
69
70 client := s3.NewFromConfig(cfg)
103 var s3Response S3Response
104 jsonString, err := json.Marshal(result)
105 if err != nil {
106 log.Fatal(err)107 }
108 json.Unmarshal(jsonString, &s3Response)
109
95
96 result, err := client.ListObjectsV2(context.TODO(), input)
97 if err != nil {
98 log.Fatal(err) 99 }
100
101 // RESPONSE HANDLING
89 res, err := io.Copy(w, resp.Body)
90
91 if err != nil {
92 log.Fatal(err)93 }
94 return res
95
80 // download the image
81 resp, err := http.Get(url)
82 if err != nil {
83 log.Fatal(err)84 }
85
86 // stream the image
Packages exposing functions that can stop program execution by exiting are hard to reuse. Program exits in functions other than main() or init() are not encouraged.
func nonMainFunc() {
safelyExit := true // somehow arrive at this value
if safelyExit {
os.Exit(0)
}
}
func main() {
nonMainFunc()
}
func nonMainFunc() bool {
safelyExit := true // somehow arrive at this value
}
func main() {
safelyExit := nonMainFunc()
if safelyExit {
os.Exit(0)
}
}