...

Source file src/github.com/tklauser/numcpus/example_test.go

Documentation: github.com/tklauser/numcpus

     1  // Copyright 2018 Tobias Klauser
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package numcpus_test
    16  
    17  import (
    18  	"fmt"
    19  	"os"
    20  
    21  	"github.com/tklauser/numcpus"
    22  )
    23  
    24  func ExampleGetOffline() {
    25  	offline, err := numcpus.GetOffline()
    26  	if err != nil {
    27  		fmt.Fprintf(os.Stderr, "GetOffline: %v\n", err)
    28  	}
    29  	fmt.Printf("# of offline CPUs: %v\n", offline)
    30  }
    31  
    32  func ExampleGetOnline() {
    33  	online, err := numcpus.GetOnline()
    34  	if err != nil {
    35  		fmt.Fprintf(os.Stderr, "GetOnline: %v\n", err)
    36  	}
    37  	fmt.Printf("# of online CPUs: %v\n", online)
    38  }
    39  
    40  func ExampleGetPossible() {
    41  	possible, err := numcpus.GetPossible()
    42  	if err != nil {
    43  		fmt.Fprintf(os.Stderr, "GetPossible: %v\n", err)
    44  	}
    45  	fmt.Printf("# of possible CPUs: %v\n", possible)
    46  }
    47  
    48  func ExampleGetPresent() {
    49  	present, err := numcpus.GetPresent()
    50  	if err != nil {
    51  		fmt.Fprintf(os.Stderr, "GetPresent: %v\n", err)
    52  	}
    53  	fmt.Printf("# of present CPUs: %v\n", present)
    54  }
    55  

View as plain text