etcd-tester: fix govet

This commit is contained in:
Gyu-Ho Lee 2016-04-13 10:52:39 -07:00
parent 35d2d7b23e
commit cb280bae91
2 changed files with 13 additions and 12 deletions

View File

@ -26,8 +26,19 @@ type statusHandler struct {
func (sh statusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
en := json.NewEncoder(w)
err := en.Encode(sh.status.get())
if err != nil {
sh.status.mu.Lock()
defer sh.status.mu.Unlock()
if err := en.Encode(Status{
Since: sh.status.Since,
Failures: sh.status.Failures,
RoundLimit: sh.status.RoundLimit,
Cluster: sh.status.cluster.Status(),
cluster: sh.status.cluster,
Round: sh.status.Round,
Case: sh.status.Case,
}); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}

View File

@ -208,16 +208,6 @@ type Status struct {
Case int
}
// get gets a copy of status
func (s *Status) get() Status {
s.mu.Lock()
got := *s
cluster := s.cluster
s.mu.Unlock()
got.Cluster = cluster.Status()
return got
}
func (s *Status) setRound(r int) {
s.mu.Lock()
defer s.mu.Unlock()