Skip to content
This repository was archived by the owner on Nov 7, 2022. It is now read-only.

Commit 57457be

Browse files
author
Paulo Janotti
authored
Remove unused code in internal package (#425)
Just removing unused code from internal package.
1 parent 7045421 commit 57457be

1 file changed

Lines changed: 0 additions & 65 deletions

File tree

internal/internal.go

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -15,78 +15,13 @@
1515
package internal
1616

1717
import (
18-
"encoding/json"
1918
"fmt"
20-
"io/ioutil"
21-
"os"
22-
"os/user"
23-
"path/filepath"
24-
"runtime"
2519
"strings"
2620
"time"
2721

2822
"github.com/golang/protobuf/ptypes/timestamp"
2923
)
3024

31-
// Service contains metadata about the exporter service.
32-
type Service struct {
33-
Endpoint string `json:"endpoint"`
34-
}
35-
36-
// WriteToEndpointFile writes service metadata to
37-
// canonical endpoint file.
38-
func (s *Service) WriteToEndpointFile() (path string, err error) {
39-
data, err := json.Marshal(s)
40-
if err != nil {
41-
return "", err
42-
}
43-
path = defaultEndpointFile()
44-
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
45-
return "", err
46-
}
47-
if err := ioutil.WriteFile(path, data, 0755); err != nil {
48-
return "", err
49-
}
50-
return path, nil
51-
}
52-
53-
// ParseEndpointFile reads and parses the canonical endpoint
54-
// file for metadata.
55-
func ParseEndpointFile() (*Service, error) {
56-
file := defaultEndpointFile()
57-
data, err := ioutil.ReadFile(file)
58-
if err != nil {
59-
return nil, err
60-
}
61-
var s Service
62-
if err := json.Unmarshal(data, &s); err != nil {
63-
return nil, err
64-
}
65-
return &s, nil
66-
}
67-
68-
// defaultEndpointFile is the location where the
69-
// endpoint file is at on the current platform.
70-
func defaultEndpointFile() string {
71-
const f = "opencensus.endpoint"
72-
if runtime.GOOS == "windows" {
73-
return filepath.Join(os.Getenv("APPDATA"), "opencensus", f)
74-
}
75-
return filepath.Join(guessUnixHomeDir(), ".config", f)
76-
}
77-
78-
func guessUnixHomeDir() string {
79-
// Prefer $HOME over user.Current due to glibc bug: golang.org/issue/13470
80-
if v := os.Getenv("HOME"); v != "" {
81-
return v
82-
}
83-
// Else, fall back to user.Current:
84-
if u, err := user.Current(); err == nil {
85-
return u.HomeDir
86-
}
87-
return ""
88-
}
89-
9025
// TimeToTimestamp converts a time.Time to a timestamp.Timestamp pointer.
9126
func TimeToTimestamp(t time.Time) *timestamp.Timestamp {
9227
if t.IsZero() {

0 commit comments

Comments
 (0)