github.com/nya3jp/tast@v0.0.0-20230601000426-85c8e4d83a9b/src/go.chromium.org/tast/core/caller/caller.go (about)

     1  // Copyright 2019 The ChromiumOS Authors
     2  // Use of this source code is governed by a BSD-style license that can be
     3  // found in the LICENSE file.
     4  
     5  // Package caller provides utilities to inspect the caller of a function.
     6  package caller
     7  
     8  import (
     9  	"go.chromium.org/tast/core/internal/caller"
    10  )
    11  
    12  // Get returns the package path-qualified name of a function in the current call
    13  // stack. skip is the number of stack frames to skip, with 0 identifying the
    14  // frame for Get itself and 1 identifying the caller of Get.
    15  // Get ignores a function in chromiumos/... calling the same function in
    16  // go.chromium.org/... . For example if go.chromium.org/tast-tests/cros/foo.Bar calls
    17  // go.chromium.org/tast/foo.Bar, Get ignores go.chromium.org/tast-tests/cros/foo.Bar.
    18  func Get(skip int) string {
    19  	return caller.Get(skip + 1)
    20  }
    21  
    22  // Check examines the current call stack and panics if a function in the
    23  // specified frame does not belong to any package in pkgs.
    24  // Get is used to find the caller with skip.
    25  func Check(skip int, pkgs []string) {
    26  	caller.Check(skip+1, pkgs)
    27  }