github.com/google/capslock@v0.2.3-0.20240517042941-dac19fc347c0/testpkgs/callos/callos.go (about)

     1  // Copyright 2023 Google LLC
     2  //
     3  // Use of this source code is governed by a BSD-style
     4  // license that can be found in the LICENSE file or at
     5  // https://developers.google.com/open-source/licenses/bsd
     6  
     7  // Package callos is used for testing.
     8  package callos
     9  
    10  import (
    11  	"os"
    12  	"os/exec"
    13  	"os/user"
    14  )
    15  
    16  // Foo is a test function.
    17  func Foo() int {
    18  	return 42 + os.Getpid()
    19  }
    20  
    21  // Bar is a test function which calls os/exec.Command and
    22  // (*os/exec.Cmd).Run.
    23  func Bar() int {
    24  	err := exec.Command("a", "b").Run()
    25  	if err != nil {
    26  		return 1
    27  	}
    28  	return 0
    29  }
    30  
    31  // Baz is a test function which calls os/user.Current.
    32  func Baz() int {
    33  	u, _ := user.Current()
    34  	return len(u.Username)
    35  }