virt

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2021 License: MIT Imports: 5 Imported by: 0

README

virt

Go Reference

Package virt is a library that helps detect if application is running in a virtual machine, container or bare-metal.

It depends on klauspost/cpuid library for getting low-level CPU flags.

Detection mechanism is based on the checks in chuckleb/virt-what.

Install

go get -u github.com/sewiti/virt

Usage Example

package main

import (
	"fmt"

	"github.com/sewiti/virt"
)

func main() {
	fmt.Println("Virtual machine: ", virt.IsVM())
	fmt.Println("Container:       ", virt.IsContainer())
}

Documentation

Overview

Package virt is a library that helps detect if application is running in a virtual machine, container or bare-metal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsContainer

func IsContainer() bool

IsContainer reports whetver application is running in a container.

func IsVM

func IsVM() bool

IsVM reports whetver application is running in a virtual machine. Uses cpuid as primary source, filesystem as fallback.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL