Skip to content

Commit b9e7f5f

Browse files
authored
fix go ci (#1473)
* fix go ci * lint ignore syntax * better linter * tidy
1 parent 5018dc7 commit b9e7f5f

13 files changed

Lines changed: 41 additions & 25 deletions

File tree

.github/workflows/buildtest.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,15 @@ jobs:
4040
go-version-file: "go.mod"
4141

4242
- name: Set up gotestfmt
43-
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@v2.4.1
43+
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@9eae5abc81d6d08f73268741ef4a8b97f29b60d8 # v2.4.1
4444

4545
- name: Download Go modules
4646
run: go mod download
4747

48-
- name: Static Check
49-
uses: amarpal/staticcheck-action@ab84170fc40f72c7045b5d669e149e06c2b96439
48+
- name: Lint
49+
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
5050
with:
51-
checks: '["all", "-ST1000", "-ST1003", "-ST1020", "-ST1021", "-ST1022", "-SA1019"]'
52-
install-go: false
51+
version: v2.11.4
5352

5453
- name: Test
5554
run: |

.golangci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: "2"
2+
linters:
3+
default: none
4+
enable:
5+
- staticcheck
6+
settings:
7+
staticcheck:
8+
checks:
9+
- "all"
10+
- "-ST1000"
11+
- "-ST1003"
12+
- "-ST1020"
13+
- "-ST1021"
14+
- "-ST1022"
15+
- "-SA1019"
16+
- "-QF1008"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/livekit/protocol
22

3-
go 1.24.0
3+
go 1.25.0
44

55
require (
66
buf.build/go/protoyaml v0.6.0

ingress/validation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func ValidateEnableTranscoding(info *livekit.IngressInfo) error {
120120
}
121121
} else {
122122
enableTranscoding = true
123-
if info.EnableTranscoding != nil && *info.EnableTranscoding == false {
123+
if info.EnableTranscoding != nil && !*info.EnableTranscoding {
124124
return NewInvalidTranscodingBypassError("bypassing transcoding impossible with selected input type")
125125
}
126126
}

livekit/sip.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func validateAttributesToHeaders(attributesToHeaders map[string]string) error {
325325

326326
// validateHeaderToAttributes Makes sure the keys of the given map correspond to valid SIP header names
327327
func validateHeaderToAttributes(headerToAttributes map[string]string) error {
328-
for headerName, _ := range headerToAttributes {
328+
for headerName := range headerToAttributes {
329329
if err := ValidateHeaderName(headerName, false); err != nil {
330330
return fmt.Errorf("invalid header name: %w", err)
331331
}

logger/zaputil/zaputil_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ func (c *testCore) With(fields []zapcore.Field) zapcore.Core {
5151
}
5252
}
5353

54-
func (s *testCore) Write(entry zapcore.Entry, fields []zapcore.Field) error {
55-
s.init()
56-
s.writeCount.Inc()
54+
func (c *testCore) Write(entry zapcore.Entry, fields []zapcore.Field) error {
55+
c.init()
56+
c.writeCount.Inc()
5757
return nil
5858
}

sip/sip.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func GetPinAndRoom(info *livekit.SIPDispatchRuleInfo) (room, pin string, err err
272272
// TODO: Could probably add methods on SIPDispatchRuleInfo struct instead.
273273
switch rule := info.GetRule().GetRule().(type) {
274274
default:
275-
return "", "", fmt.Errorf("Unsupported SIP Dispatch Rule: %T", rule)
275+
return "", "", fmt.Errorf("Unsupported SIP Dispatch Rule: %T", rule) //nolint:staticcheck // part of public API
276276
case *livekit.SIPDispatchRule_DispatchRuleDirect:
277277
pin = rule.DispatchRuleDirect.GetPin()
278278
room = rule.DispatchRuleDirect.GetRoomName()
@@ -874,7 +874,7 @@ func EvaluateDispatchRule(projectID string, trunk *livekit.SIPInboundTrunkInfo,
874874
// This should never happen in practice, because matchSIPDispatchRule should remove rules with the wrong pin.
875875
return nil, twirp.NewError(twirp.PermissionDenied, "Incorrect PIN for SIP room")
876876
}
877-
} else {
877+
} else { //nolint:staticcheck // empty branch provides context for comment
878878
// Pin was sent, but room doesn't require one. Assume user accidentally pressed phone button.
879879
}
880880
switch rule := rule.GetRule().GetRule().(type) {
@@ -898,19 +898,19 @@ func EvaluateDispatchRule(projectID string, trunk *livekit.SIPInboundTrunkInfo,
898898
room += "_" + guid.New("")
899899
}
900900
}
901-
attrs[livekit.AttrSIPDispatchRuleID] = rule.SipDispatchRuleId
901+
attrs[livekit.AttrSIPDispatchRuleID] = rule.GetSipDispatchRuleId()
902902
resp := &rpc.EvaluateSIPDispatchRulesResponse{
903903
ProjectId: projectID,
904904
SipTrunkId: trunkID,
905-
SipDispatchRuleId: rule.SipDispatchRuleId,
905+
SipDispatchRuleId: rule.GetSipDispatchRuleId(),
906906
Result: rpc.SIPDispatchResult_ACCEPT,
907907
RoomName: room,
908908
ParticipantIdentity: fromID,
909909
ParticipantName: fromName,
910-
ParticipantMetadata: rule.Metadata,
910+
ParticipantMetadata: rule.GetMetadata(),
911911
ParticipantAttributes: attrs,
912-
RoomPreset: rule.RoomPreset,
913-
RoomConfig: rule.RoomConfig,
912+
RoomPreset: rule.GetRoomPreset(),
913+
RoomConfig: rule.GetRoomConfig(),
914914
MediaEncryption: enc,
915915
}
916916
krispEnabled := false

utils/deepcopy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type copyTestType struct {
2828
Vmap map[int]int
2929
Vpointer *copyTestType
3030
VunsafePointer unsafe.Pointer
31-
vunexported bool
31+
vunexported bool //nolint:unused // tests deep copy of unexported fields
3232
}
3333

3434
func TestDeepCopy(t *testing.T) {

utils/events/emitter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ type blockingObserver[V any] struct {
301301
ch chan V
302302
}
303303

304-
func (o *blockingObserver[V]) emit(v V) {
304+
func (o *blockingObserver[V]) emit(v V) { //nolint:unused // implements Observer interface
305305
select {
306306
case o.ch <- v:
307307
case <-o.done:
@@ -318,7 +318,7 @@ func (o *blockingObserver[V]) Events() <-chan V {
318318

319319
type nonblockingCallback[V any] func(V)
320320

321-
func (o nonblockingCallback[V]) emit(v V) {
321+
func (o nonblockingCallback[V]) emit(v V) { //nolint:unused // implements Observer interface
322322
go o(v)
323323
}
324324

@@ -328,7 +328,7 @@ func (o nonblockingCallback[V]) Events() <-chan V { return nil }
328328

329329
type blockingCallback[V any] func(V)
330330

331-
func (o blockingCallback[V]) emit(v V) {
331+
func (o blockingCallback[V]) emit(v V) { //nolint:unused // implements Observer interface
332332
o(v)
333333
}
334334

utils/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type Hook[T any] struct {
55
prev *T
66
}
77

8-
func (h *Hook[T]) getListHook() *Hook[T] {
8+
func (h *Hook[T]) getListHook() *Hook[T] { //nolint:unused // implements hookAccessor interface
99
return h
1010
}
1111

0 commit comments

Comments
 (0)