Skip to content

Commit

Permalink
gofmt code
Browse files Browse the repository at this point in the history
  • Loading branch information
shimmeris committed Jan 9, 2023
1 parent e7dcc4d commit 414c514
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 15 deletions.
5 changes: 3 additions & 2 deletions cmd/socks.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func invoke(providerConfigPath, message string) {
}

for provider, rmap := range conf.Records {
for region, _ := range rmap {
for region := range rmap {
go func(provider, region string) {
p, err := createProvider(provider, region, providerConfig)
if err != nil {
Expand All @@ -71,7 +71,7 @@ func invoke(providerConfigPath, message string) {
}

opts := &sdk.FunctionOpts{
Namespace: Namespace,
Namespace: Namespace,
FunctionName: SocksFunctionName,
}
err = sp.InvokeFunction(opts, message)
Expand Down Expand Up @@ -110,6 +110,7 @@ func (m *Message) Json() string {
}

var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

func randomString(n int) string {
b := make([]rune, n)
for i := range b {
Expand Down
2 changes: 1 addition & 1 deletion sdk/options.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package sdk

type FunctionOpts struct {
Namespace string
Namespace string
FunctionName string
TriggerName string
OnlyTrigger bool
Expand Down
1 change: 0 additions & 1 deletion sdk/provider/alibaba/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func (p *Provider) Region() string {
return p.region
}


func Regions() []string {
return []string{
"ap-northeast-1",
Expand Down
3 changes: 1 addition & 2 deletions sdk/provider/alibaba/socks.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ func (p *Provider) createSocksFunction(serviceName, functionName string) error {
return nil
}


func (p *Provider) InvokeFunction(opts *sdk.FunctionOpts, message string) error {
h := &fcopen.InvokeFunctionHeaders{XFcInvocationType: tea.String("Async")}
r := &fcopen.InvokeFunctionRequest{Body: []byte(message)}

_, err := p.fclient.InvokeFunctionWithOptions(tea.String(opts.Namespace), tea.String(opts.FunctionName), r, h, p.runtime)
return err
}
}
12 changes: 6 additions & 6 deletions sdk/provider/huawei/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ import (

const GroupName = "scf"

func (p *Provider) DeployHttpProxy(opts *sdk.HttpProxyOpts) (*sdk.DeployHttpProxyResult, error) {
func (p *Provider) DeployHttpProxy(opts *sdk.FunctionOpts) (string, error) {
if err := p.createGroup(GroupName); err != nil {
return nil, err
return "", err
}

functionUrn, err := p.createFunction(opts.FunctionName)
if err != nil {
return nil, err
return "", err
}

triggerId, err := p.createHttpTrigger(functionUrn, opts.TriggerName)
api, err := p.createHttpTrigger(functionUrn, opts.TriggerName)
if err != nil {
return nil, err
return "", err
}

return &sdk.DeployHttpProxyResult{API: triggerId, Region: p.region, Provider: p.Name()}, nil
return api, nil

}

Expand Down
1 change: 0 additions & 1 deletion sdk/provider/tencent/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func (p *Provider) Region() string {
return p.region
}


func Regions() []string {
// 腾讯云大陆外地区部署延迟巨大,暂不进行部署
return []string{
Expand Down
4 changes: 2 additions & 2 deletions sdk/provider/tencent/socks.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (p *Provider) DeploySocksProxy(opts *sdk.FunctionOpts) error {
}

func (p *Provider) ClearSocksProxy(opts *sdk.FunctionOpts) error {
return p.deleteFunction(opts.Namespace, opts.FunctionName);
return p.deleteFunction(opts.Namespace, opts.FunctionName)
}

func (p *Provider) createSocksFunction(namespace, functionName string) error {
Expand Down Expand Up @@ -50,4 +50,4 @@ func (p *Provider) InvokeFunction(opts *sdk.FunctionOpts, message string) error
_, err := p.fclient.Invoke(r)
return err

}
}

0 comments on commit 414c514

Please sign in to comment.