Within my project I have 2 files, main.go
and price.go
; in my main.go
file inside the main()
function I tried to call a function from the price
file that is exportable (starts with a capital letter), and when trying to execute I get the error that the function was not defined; >
./ main.go: 13: 30: undefined: GetPrice
Code:
main.go:
package main
import ( ... )
func main() {
router := mux.NewRouter()
// Router registry for "/price" endpoint
router.HandleFunc("/price", GetPrice).Methods("POST")
http.ListenAndServe(":8080", router)
}
price.go:
package main
import (...)
// Price represent all fields in prices request
type Price struct {
SKU string 'json:"sku"'
SellerID string 'json:"seller_id"'
}
// GetPrice retrieve a json response to requested price
func GetPrice(writter http.ResponseWriter, request *http.Request) {
fmt.Println("Hello! GET PRICE!")
}
Even declaring an "exportable" function because I keep getting this error?