https://domain.com/products/chairs?height=200&width=100
r.HandleFunc("/products/{category_handle}", h.ShowProducts).Methods("GET")
vars := mux.Vars(r)
categoryHandle := vars["categoryHandle"]
height, _ := strconv.Atoi(r.URL.Query().Get("height"))
width, _ := strconv.Atoi(r.URL.Query().Get("width"))
r.HandleFunc("/post/{Id}", h.GetPost).Methods("GET")
r.HandleFunc("/post", h.GetPost).Methods("GET")
id, err := strconv.Atoi(r.URL.Query().Get("Id"))
id, err := strconv.Atoi(r.URL.Query().Get("Id"))
func SortBytes(data []byte) {
sort.Slice(data func(i, j int) bool {
return data[i] < data[j]
})
}
// потом использовать вот так
arr1 := []byte{4, 3, 2, 1, 6, 3, 77, 8,3}
sortBytes(arr1)
fmt.Println(arr1)
arr2 := []byte{5, 1, 4, 3, 2, 1, 6, 3, 77, 8,3}
sortBytes(arr2)
fmt.Println(arr2)
type slice struct {
array unsafe.Pointer
len int
cap int
}
_, err := tx.Exec("INSERT INTO author (first_name, last_name, middle_name, position) VALUES ($1, $2, $3, $4)", test.signer.lastname, test.signer.firstname, test.signer.surname, test.signer.position)
if err != nil {
log.Prinf("Insert into author error: %v\n", err)
tx.Rollback()
break
}
_, err = tx.Exec("INSERT INTO organization (name_organization) VALUES ($1)", test.organization.title)
if err != nil {
log.Prinf("Insert into author error: %v\n", err)
tx.Rollback()
break
}
for _, user := range users {
_, err := tx.Exec(`INSERT INTO users (поля таблицы...) VALUES ($1, $2...)`)
// если во время запрос произошла ошибка - транзакцию нужно откатить
if err != nil {
tx.Rollback()
break
}
tx.Exec(`INSERT INTO user_categories (поля таблицы...) VALUES ($1, $2...)`)
}