func init() { godotenv.Load() // err := godotenv.Load() // if err != nil { // log.Fatal("Error loading .env file") // } BUCKET = aws.String(os.Getenv("BUCKET")) SVC = s3.New(aws.NewConfig().WithRegion(os.Getenv("AWS_REGION")).WithS3ForcePathStyle(true)) }
func main() { defer db.Close() godotenv.Load() if os.Getenv("ENV") != "production" { factory.AutoMigrate() s3s.Test() } else { log.Println("Production") } log.Fatal(http.ListenAndServe(":"+os.Getenv("PORT"), api_srv.New())) }
func main() { defer db.Close() godotenv.Load() if os.Getenv("ENV") != "production" { factory.AutoMigrate() s3s.Test() } else { log.Println("Production") } // Route settings router := mux.NewRouter().StrictSlash(true) router. HandleFunc("/user", handlers.Register). Methods("POST") router. HandleFunc("/user/login", handlers.Login). Methods("GET") router. HandleFunc("/user/{userId}", handlers.GetUserById). Methods("GET") router. HandleFunc("/user/{userId}/photos", handlers.GetPhotosByUserId). Methods("GET") router. HandleFunc("/user/{userId}", handlers.UpdateUser). Methods("POST") router. HandleFunc("/photos", handlers.GetPhotos). Methods("GET") router. HandleFunc("/photo", handlers.PostPhoto). Methods("POST") router. HandleFunc("/photo/{photoId}/comment", handlers.CreateComment). Methods("POST") // Bind to a port and pass our router in http.Handle("/", &MyServer{router}) log.Fatal(http.ListenAndServe(":"+os.Getenv("PORT"), nil)) }
func init() { godotenv.Load() connString := getStandardizedConnStr(os.Getenv("CLEARDB_DATABASE_URL")) // log.Println(connString) Conn, _ = gorm.Open("mysql", connString) Conn.SingularTable(true) log.Println(Conn.DB().Ping()) if os.Getenv("ENV") != "production" { Conn.LogMode(true) } }
func init() { godotenv.Load() }