Skip to content
This repository was archived by the owner on Jan 22, 2022. It is now read-only.
This repository was archived by the owner on Jan 22, 2022. It is now read-only.

failed to print string array #42

@changsijay

Description

@changsijay

I am trying to print the gateway of each NetAdapter by following code,
It print [] for all netadapters, not sure if this is a bug.

package main

import "github.com/StackExchange/wmi"
import "fmt"

// https://msdn.microsoft.com/en-us/library/aa394217(v=vs.85).aspx
type Win32_NetworkAdapterConfiguration struct {
	IPAddress []string
	DHCPServer string
	MACAddress string
	DefaultIPGateway []string
}

func main() {
	var dst2 []Win32_NetworkAdapterConfiguration
	query := fmt.Sprintf("")
	q := wmi.CreateQuery(&dst2, query)
	err := wmi.Query(q, &dst2)
	if err != nil {
		fmt.Println(err)
	}
	for _, v := range dst2 {
		fmt.Println(v.MACAddress, v.IPAddress, v.DHCPServer, v.DefaultIPGateway)
	}	
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions