diff --git a/internal/pgopher/collector.go b/internal/pgopher/collector.go index e257416..6d52cf8 100644 --- a/internal/pgopher/collector.go +++ b/internal/pgopher/collector.go @@ -85,7 +85,7 @@ func (p profileCollector) Run() { case "kubernetes": name := fmt.Sprintf("pgopher-profile-%s", p.target.Name) - profileData := make([]byte, 0, buf.Len()) + profileData := make([]byte, base64.StdEncoding.EncodedLen(buf.Len())) base64.StdEncoding.Encode(profileData, buf.Bytes()) diff --git a/internal/pgopher/http.go b/internal/pgopher/http.go index 65bcf63..47a7b0e 100644 --- a/internal/pgopher/http.go +++ b/internal/pgopher/http.go @@ -84,7 +84,7 @@ func (s *Server) handleProfile(ctx echo.Context) error { defer file.Close() defer os.Remove(file.Name()) - profileData := make([]byte, 0, len(resp.Data["profile"])) + profileData := make([]byte, base64.StdEncoding.DecodedLen(len(resp.Data["profile"]))) _, err = base64.StdEncoding.Decode(profileData, resp.Data["profile"]) if err != nil {