/
wax_boy
/
semaphore_custom
Обзор
Документация
Войти
/
wax_boy
/
semaphore_custom
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
api/apps_test.go
44 строки
781 B
Denis Gukov
sec/golangci (#3817)
02 май 2026, 16:52
Не верифицирован
02 май 2026, 16:52
71e2baf
Код
Авторство
О чём код?
package api import ( "fmt" "testing" "github.com/semaphoreui/semaphore/pkg/conv" ) func TestStructToMap(t *testing.T) { type Address struct { City string `json:"city"` State string `json:"state"` } type Person struct { Name string `json:"name"` Age int `json:"age"` Email string `json:"email"` Active bool `json:"active"` Address Address `json:"address"` } // Create an instance of the struct p := Person{ Name: "John Doe", Age: 30, Email: "johndoe@example.com", Active: true, Address: Address{ City: "New York", State: "NY", }, } // Convert the struct to a flat map flatMap := conv.StructToFlatMap(&p) if flatMap["address.city"] != "New York" { t.Fail() } // Print the map fmt.Println(flatMap) }