Skip to content

Commit

Permalink
chore: apply run fmt to all files
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianoliveira committed May 23, 2023
1 parent 50b118c commit 40f8219
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 27 deletions.
1 change: 0 additions & 1 deletion commands/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
// Usage:
//
// `ergo setup osx`
//
type SetupCommand struct {
System string
Remove bool
Expand Down
8 changes: 4 additions & 4 deletions commands/setup/system_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

package setup

//ShowInternetOptions is just a dummy for now
//this is only used for Windows
// ShowInternetOptions is just a dummy for now
// this is only used for Windows
func ShowInternetOptions() {}

//InetRefresh is just a dummy. It only has functionality
//in Windows
// InetRefresh is just a dummy. It only has functionality
// in Windows
func InetRefresh() {}
14 changes: 7 additions & 7 deletions commands/setup/system_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"syscall"
)

//ShowInternetOptions will display the Internet Options
//control panel. If the user clicks OK here, then the modifications
//will be visible without a restart
//this is just a fallback for the InetRefresh function
// ShowInternetOptions will display the Internet Options
// control panel. If the user clicks OK here, then the modifications
// will be visible without a restart
// this is just a fallback for the InetRefresh function
func ShowInternetOptions() {
cmd := exec.Command("control", "inetcpl.cpl,Connections,4")
fmt.Println("Starting the Internet Options control panel")
Expand All @@ -22,9 +22,9 @@ func ShowInternetOptions() {
}
}

//InetRefresh will inform windows that a proxy change was performed.
//if windows is not informed about the change, then the modification will only be noticed
//after a restart
// InetRefresh will inform windows that a proxy change was performed.
// if windows is not informed about the change, then the modification will only be noticed
// after a restart
func InetRefresh() {
wininet := syscall.MustLoadDLL("wininet.dll")
inetsetoption := wininet.MustFindProc("InternetSetOptionW")
Expand Down
24 changes: 12 additions & 12 deletions proxy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"
)

//Service holds the details of the service (Name and URL)
// Service holds the details of the service (Name and URL)
type Service struct {
Name string
URL string
Expand All @@ -23,7 +23,7 @@ func (s Service) Empty() bool {
return s.Name == "" || s.URL == ""
}

//Config holds the configuration for the proxy.
// Config holds the configuration for the proxy.
type Config struct {
mutex sync.Mutex
lastChange time.Time
Expand All @@ -36,7 +36,7 @@ type Config struct {
ConfigFile string
}

//Defines the name of ergo env variable for configuration.
// Defines the name of ergo env variable for configuration.
const (
PortEnv = "ERGO_PORT"
DomainEnv = "ERGO_DOMAIN"
Expand All @@ -48,7 +48,7 @@ const (
ConfigFilePathDefault = "./.ergo"
)

//NewConfig gets the defaults config.
// NewConfig gets the defaults config.
func NewConfig() *Config {
var config = &Config{
Port: PortDefault,
Expand Down Expand Up @@ -76,8 +76,8 @@ func NewConfig() *Config {
return config
}

//OverrideBy makes sure that it sets the correct config based on
//the defaults and the passed by argument
// OverrideBy makes sure that it sets the correct config based on
// the defaults and the passed by argument
func (c *Config) OverrideBy(new *Config) {
if new.Port != "" {
c.Port = new.Port
Expand All @@ -99,7 +99,7 @@ func (c *Config) OverrideBy(new *Config) {
var once sync.Once
var domainPattern *regexp.Regexp

//GetService gets the service for the given host.
// GetService gets the service for the given host.
func (c *Config) GetService(host string) Service {
once.Do(func() {
domainPattern = regexp.MustCompile(`((\w*\:\/\/)?.+)(` + c.Domain + `)`)
Expand All @@ -114,12 +114,12 @@ func (c *Config) GetService(host string) Service {
return c.Services[parts[0][1]]
}

//GetProxyPacURL returns the correct url for the pac file
// GetProxyPacURL returns the correct url for the pac file
func (c *Config) GetProxyPacURL() string {
return "http://127.0.0.1:" + c.Port + "/proxy.pac"
}

//AddService add a service using the correct key
// AddService add a service using the correct key
func (c *Config) AddService(service Service) error {
if service.Empty() {
return fmt.Errorf("Service is invalid")
Expand All @@ -129,8 +129,8 @@ func (c *Config) AddService(service Service) error {
return nil
}

//LoadServices loads the services from filepath, returns an error
//if the configuration could not be parsed
// LoadServices loads the services from filepath, returns an error
// if the configuration could not be parsed
func (c *Config) LoadServices() error {
services, err := readServicesFromFile(c.ConfigFile)
fmt.Println("services", services)
Expand Down Expand Up @@ -217,7 +217,7 @@ func readServicesFromFile(filepath string) ([]Service, error) {
return services, nil
}

//AddService adds new service to the filepath
// AddService adds new service to the filepath
func AddService(filepath string, service Service) error {
file, e := os.OpenFile(filepath, os.O_APPEND|os.O_WRONLY, os.ModeAppend)

Expand Down
4 changes: 2 additions & 2 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"
)

//NewErgoProxy returns the new reverse proxy.
// NewErgoProxy returns the new reverse proxy.
func NewErgoProxy(config *Config) *httputil.ReverseProxy {
director := func(req *http.Request) {
t := time.Now()
Expand Down Expand Up @@ -51,7 +51,7 @@ func NewErgoProxy(config *Config) *httputil.ReverseProxy {
}
}

//ServeProxy listens & serves the HTTP proxy.
// ServeProxy listens & serves the HTTP proxy.
func ServeProxy(config *Config) error {
ticker := time.NewTicker(500 * time.Millisecond)
defer ticker.Stop()
Expand Down
2 changes: 1 addition & 1 deletion proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func TestPollConfigChangeWithValidConfigFile(t *testing.T) {
}
}

//structure to mock a http ResponseWriter
// structure to mock a http ResponseWriter
type mockHTTPResponse struct {
WrittenData []byte
WrittenHeader int
Expand Down

0 comments on commit 40f8219

Please sign in to comment.