Skip to content

Commit

Permalink
gofumpt and gci
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulexus committed Sep 4, 2023
1 parent fd93598 commit 047ffe8
Show file tree
Hide file tree
Showing 36 changed files with 164 additions and 52 deletions.
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.0/direnvrc" "sha256-5EwyKnkJNQeXrRkYbwwRBcXbibosCJqyIUuz9Xq+LRc="
fi
use flake
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ _obj
_test
bin
vendor/
/.direnv/

# Architecture specific extensions/prefixes
*.[568vq]
Expand Down
9 changes: 4 additions & 5 deletions application.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ari
// Application represents a communication path interacting with an Asterisk
// server for application-level resources
type Application interface {

// List returns the list of applications in Asterisk, optionally using the key for filtering
List(*Key) ([]*Key, error)

Expand Down Expand Up @@ -72,10 +71,10 @@ func (ah *ApplicationHandle) Data() (ad *ApplicationData, err error) {

// Subscribe subscribes the application to an event source
// event source may be one of:
// - channel:<channelId>
// - bridge:<bridgeId>
// - endpoint:<tech>/<resource> (e.g. SIP/102)
// - deviceState:<deviceName>
// - channel:<channelId>
// - bridge:<bridgeId>
// - endpoint:<tech>/<resource> (e.g. SIP/102)
// - deviceState:<deviceName>
func (ah *ApplicationHandle) Subscribe(eventSource string) (err error) {
err = ah.a.Subscribe(ah.key, eventSource)
return
Expand Down
4 changes: 1 addition & 3 deletions asterisk.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ari
// Asterisk represents a communication path for
// the Asterisk server for system-level resources
type Asterisk interface {

// Info gets data about the asterisk system
Info(key *Key) (*AsteriskInfo, error)

Expand Down Expand Up @@ -41,7 +40,7 @@ type BuildInfo struct {
// ConfigInfo describes information about the Asterisk configuration
type ConfigInfo struct {
DefaultLanguage string `json:"default_language"`
MaxChannels int `json:"max_channels,omitempty"` //omitempty denotes an optional field, meaning the field may not be present if no value is assigned.
MaxChannels int `json:"max_channels,omitempty"` // omitempty denotes an optional field, meaning the field may not be present if no value is assigned.
MaxLoad float64 `json:"max_load,omitempty"`
MaxOpenFiles int `json:"max_open_files,omitempty"`
Name string `json:"name"` // Asterisk system name
Expand All @@ -68,7 +67,6 @@ type SystemInfo struct {

// AsteriskVariables is an interface to interact with Asterisk global variables
type AsteriskVariables interface {

// Get returns the value of the given variable; the ID field of the Key is the variable name
Get(key *Key) (string, error)

Expand Down
2 changes: 0 additions & 2 deletions bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ari
// Bridge represents a communication path to an
// Asterisk server for working with bridge resources
type Bridge interface {

// Create creates a bridge
Create(key *Key, btype string, name string) (*BridgeHandle, error)

Expand Down Expand Up @@ -78,7 +77,6 @@ type BridgeData struct {

// BridgeAddChannelOptions describes additional options to be applied to a channel when it is joined to a bridge
type BridgeAddChannelOptions struct {

// AbsorbDTMF indicates that DTMF coming from this channel will not be passed through to the bridge
AbsorbDTMF bool

Expand Down
4 changes: 2 additions & 2 deletions callerid.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package ari

import "errors"

//NOTE: Direct translation from ARI client 2.0
// NOTE: Direct translation from ARI client 2.0

// CallerIDFromString interprets the provided string
// as a CallerID. Usually, this string will be of the following forms:
// - "Name" <number>
// - <number>
// - "Name" number
func CallerIDFromString(src string) (*CallerID, error) {
//TODO: implement complete callerid parser
// TODO: implement complete callerid parser
return nil, errors.New("CallerIDFromString not yet implemented")
}

Expand Down
1 change: 0 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package ari
// with an Asterisk ARI server. It is agnostic to transport
// and implementation.
type Client interface {

// ApplicationName returns the ARI application name by which this client is connected
ApplicationName() string

Expand Down
3 changes: 2 additions & 1 deletion client/native/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package native
import (
"fmt"

"github.com/CyCoreSystems/ari/v6"
"github.com/rotisserie/eris"

"github.com/CyCoreSystems/ari/v6"
)

// Application is a native implementation of ARI's Application functions
Expand Down
3 changes: 2 additions & 1 deletion client/native/asterisk.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package native
import (
"fmt"

"github.com/CyCoreSystems/ari/v6"
"github.com/rotisserie/eris"

"github.com/CyCoreSystems/ari/v6"
)

// Asterisk provides the ARI Asterisk accessors for a native client
Expand Down
10 changes: 5 additions & 5 deletions client/native/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ import (
"sync"
"time"

"github.com/inconshreveable/log15"
"github.com/rotisserie/eris"
"golang.org/x/net/websocket"

"github.com/CyCoreSystems/ari/v6"
"github.com/CyCoreSystems/ari/v6/rid"
"github.com/CyCoreSystems/ari/v6/stdbus"
"github.com/rotisserie/eris"

"github.com/inconshreveable/log15"
"golang.org/x/net/websocket"
)

// Logger defaults to a discard handler (null output).
// If you wish to enable logging, you can set your own
// handler like so:
// ari.Logger.SetHandler(log15.StderrHandler)
//
// ari.Logger.SetHandler(log15.StderrHandler)
var Logger = log15.New()

func init() {
Expand Down
3 changes: 2 additions & 1 deletion client/native/config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package native

import (
"github.com/CyCoreSystems/ari/v6"
"github.com/rotisserie/eris"

"github.com/CyCoreSystems/ari/v6"
)

// Config provides the ARI Configuration accessors for a native client
Expand Down
3 changes: 2 additions & 1 deletion client/native/logging.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package native

import (
"github.com/CyCoreSystems/ari/v6"
"github.com/rotisserie/eris"

"github.com/CyCoreSystems/ari/v6"
)

// Logging provides the ARI Logging accessors for a native client
Expand Down
3 changes: 1 addition & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
// Config represents a transport to the asterisk
// config ARI resource.
type Config interface {

// Get gets the reference to a config object
Get(key *Key) *ConfigHandle

Expand Down Expand Up @@ -40,7 +39,7 @@ func (cd *ConfigData) ID() string {
return fmt.Sprintf("%s/%s/%s", cd.Class, cd.Type, cd.Name)
}

//ConfigTupleList wrap a list for asterisk ari require.
// ConfigTupleList wrap a list for asterisk ari require.
type ConfigTupleList struct {
Fields []ConfigTuple `json:"fields"`
}
Expand Down
4 changes: 2 additions & 2 deletions datetime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ var dtMarshalTests = []struct {
Output string
HasError bool
}{
{dtTest{DateTime(time.Date(2005, 02, 04, 13, 12, 6, 0, time.UTC))}, `{"dt":"2005-02-04T13:12:06.000+0000"}`, false},
{dtTest{DateTime(time.Date(2005, 0o2, 0o4, 13, 12, 6, 0, time.UTC))}, `{"dt":"2005-02-04T13:12:06.000+0000"}`, false},
}

var dtUnmarshalTests = []struct {
Input string
Output dtTest
HasError bool
}{
{`{"dt":"2005-02-04T13:12:06.000+0000"}`, dtTest{DateTime(time.Date(2005, 02, 04, 13, 12, 6, 0, time.UTC))}, false},
{`{"dt":"2005-02-04T13:12:06.000+0000"}`, dtTest{DateTime(time.Date(2005, 0o2, 0o4, 13, 12, 6, 0, time.UTC))}, false},
{`{"dt":"2x05-02-04T13:12:06.000+0000"}`, dtTest{}, true},
{`{"dt": 0 }`, dtTest{}, true},
}
Expand Down
1 change: 0 additions & 1 deletion endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const EndpointIDSeparator = "|" // TODO: confirm separator isn't terrible
// Endpoint represents a communication path to an Asterisk server
// for endpoint resources
type Endpoint interface {

// List lists the endpoints
List(filter *Key) ([]*Key, error)

Expand Down
1 change: 0 additions & 1 deletion events_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ func init() {
Events.StasisEnd = "StasisEnd"
Events.StasisStart = "StasisStart"
Events.TextMessageReceived = "TextMessageReceived"

}

// DecodeEvent converts a JSON-encoded event to an ARI event.
Expand Down
1 change: 0 additions & 1 deletion ext/bridgemon/bridgemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ func (m *Monitor) Key() *ari.Key {
// destoyed.
//
// NOTE: the user should NEVER close this channel directly.
//
func (m *Monitor) Watch() <-chan *ari.BridgeData {
ch := make(chan *ari.BridgeData)

Expand Down
2 changes: 1 addition & 1 deletion ext/play/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import "github.com/inconshreveable/log15"
// Logger defaults to a discard handler (null output).
// If you wish to enable logging, you can set your own
// handler like so:
// ari.Logger.SetHandler(log15.StderrHandler)
//
// ari.Logger.SetHandler(log15.StderrHandler)
var Logger = log15.New()

func init() {
Expand Down
7 changes: 3 additions & 4 deletions ext/play/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,11 @@ func PlaybackStartTimeout(timeout time.Duration) OptionFunc {

// DigitTimeouts sets the digit timeouts. Passing a negative value to any of these indicates that the default value (shown in parentheses below) should be used.
//
// - First digit timeout (4 sec): The time (after the stop of the audio) to wait for the first digit to be received
// - First digit timeout (4 sec): The time (after the stop of the audio) to wait for the first digit to be received
//
// - Inter digit timeout (3 sec): The time (after receiving a digit) to wait for the _next_ digit to be received
//
// - Overall digit timeout (3 min): The maximum amount of time to wait (after the stop of the audio) for digits to be received, regardless of the digit frequency
// - Inter digit timeout (3 sec): The time (after receiving a digit) to wait for the _next_ digit to be received
//
// - Overall digit timeout (3 min): The maximum amount of time to wait (after the stop of the audio) for digits to be received, regardless of the digit frequency
func DigitTimeouts(first, inter, overall time.Duration) OptionFunc {
return func(o *Options) error {
if first >= 0 {
Expand Down
4 changes: 2 additions & 2 deletions ext/play/play_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"testing"
"time"

"github.com/stretchr/testify/mock"

"github.com/CyCoreSystems/ari/v6"
"github.com/CyCoreSystems/ari/v6/client/arimocks"

"github.com/stretchr/testify/mock"
)

type playStagedTest struct {
Expand Down
3 changes: 2 additions & 1 deletion ext/play/sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"context"
"time"

"github.com/rotisserie/eris"

"github.com/CyCoreSystems/ari/v6"
"github.com/CyCoreSystems/ari/v6/rid"
"github.com/rotisserie/eris"
)

// sequence represents an audio sequence playback session
Expand Down
4 changes: 2 additions & 2 deletions ext/play/sequence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"testing"
"time"

"github.com/stretchr/testify/mock"

"github.com/CyCoreSystems/ari/v6"
"github.com/CyCoreSystems/ari/v6/client/arimocks"

"github.com/stretchr/testify/mock"
)

type sequenceTest struct {
Expand Down
2 changes: 1 addition & 1 deletion ext/play/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (s *playSession) Stop() {
}

s.mu.Lock()

if !s.closed {
s.closed = true
close(s.done)
Expand Down
2 changes: 1 addition & 1 deletion ext/record/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import "github.com/inconshreveable/log15"
// Logger defaults to a discard handler (null output).
// If you wish to enable logging, you can set your own
// handler like so:
// ari.Logger.SetHandler(log15.StderrHandler)
//
// ari.Logger.SetHandler(log15.StderrHandler)
var Logger = log15.New()

func init() {
Expand Down
3 changes: 2 additions & 1 deletion ext/record/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"sync"
"time"

"github.com/rotisserie/eris"

"github.com/CyCoreSystems/ari/v6"
"github.com/CyCoreSystems/ari/v6/rid"
"github.com/rotisserie/eris"
)

var (
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 047ffe8

Please sign in to comment.