github.com/Johnny2210/revive@v1.0.8-0.20210625134200-febf37ccd0f5/testdata/golint/context-as-argument.go (about)

     1  // Test that context.Context is the first arg to a function.
     2  
     3  // Package foo ...
     4  package foo
     5  
     6  import (
     7  	"context"
     8  )
     9  
    10  // A proper context.Context location
    11  func x(ctx context.Context) { // ok
    12  }
    13  
    14  // A proper context.Context location
    15  func x(ctx context.Context, s string) { // ok
    16  }
    17  
    18  // An invalid context.Context location
    19  func y(s string, ctx context.Context) { // MATCH /context.Context should be the first parameter of a function/
    20  }
    21  
    22  // An invalid context.Context location with more than 2 args
    23  func y(s string, r int, ctx context.Context, x int) { // MATCH /context.Context should be the first parameter of a function/
    24  }
    25  
    26  func y(ctx1 context.Context, ctx2 context.Context, x int) {}
    27  
    28  func y(ctx1 context.Context, ctx2 context.Context, x int, ctx3 context.Context) {} // MATCH /context.Context should be the first parameter of a function/