package gitea import ( "encoding/json" "fmt" "net/http" ) type Repository struct { Id uint Name string Owner string Full_name string } func NewRepository(name, owner string) (repo Repository) { repo.Name = name repo.Owner = owner repo.Full_name = fmt.Sprintf("%s/%s", owner, name) return } func (gitea *Gitea) VerifyRepository(repository Repository) (Repository, error) { url := fmt.Sprintf("%s/repos/%s", gitea.Url(), repository.Full_name) response, err := http.Get(url) if err != nil { return repository, err } defer response.Body.Close() var data map[string]interface{} decoder := json.NewDecoder(response.Body) if err = decoder.Decode(&data); err != nil { return repository, err } // extract the id value to the current repository // NOTE: there may be other informations we also want to capture here as well repository.Id = uint(data["id"].(float64)) return repository, nil }