MacFastLookup/service/update.go

29 lines
432 B
Go

package service
import (
"io"
"net/http"
)
type UpdateService struct {
Url string
}
func NewUpdateService(url string) *UpdateService {
return &UpdateService{Url: url}
}
func (updater *UpdateService) GetLatestVersion() *string {
res, err := http.Get(updater.Url)
if err != nil {
return nil
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
return nil
}
str := string(body)
return &str
}