You've already forked libdetectcloud
mirror of
https://github.com/netbirdio/libdetectcloud.git
synced 2026-05-22 17:09:55 -07:00
22 lines
366 B
Go
22 lines
366 B
Go
package libdetectcloud
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
func detectGCE() string {
|
|
r, err := http.NewRequest("GET", "http://metadata.google.internal", nil)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
r.Header.Add("Metadata-Flavor", "Google")
|
|
resp, err := hc.Do(r)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
if resp.StatusCode == http.StatusOK {
|
|
return "Google Compute Engine"
|
|
}
|
|
return ""
|
|
}
|