windows

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: BSD-3-Clause Imports: 0 Imported by: 8

README

GitHub release Build Status Coverage Status Go Report Card GoDoc Go version Go version

windows

A collection of types native to Windows but are useful on non-Windows platforms.

The FILETIME-equivalent type is the sole export which is a 1:1 copy of the type found in the golang.org/x/sys/windows package. That package only builds on GOOS=windows and this particular type gets used in other protocols and file types such as NTLMv2 and 7-zip.

Documentation

Overview

Package windows is a collection of types native to Windows platforms but are useful on non-Windows platforms.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filetime

type Filetime struct {
	LowDateTime  uint32
	HighDateTime uint32
}

Filetime mirrors the Windows FILETIME structure which represents time as the number of 100-nanosecond intervals that have elapsed since 00:00:00 UTC, January 1, 1601. This code is taken from the golang.org/x/sys/windows package where it's not available for non-Windows platforms however various file formats and protocols pass this structure about so it's useful to have it available for interoperability purposes.

func NsecToFiletime

func NsecToFiletime(nsec int64) (ft Filetime)

NsecToFiletime converts nanoseconds to the equivalent Filetime type.

Example
package main

import (
	"fmt"
	"time"

	"github.com/bodgit/windows"
)

func main() {
	ft := windows.NsecToFiletime(time.Date(2020, 7, 20, 17, 15, 10, 0, time.UTC).UnixNano())

	fmt.Println(ft)
}
Output:

{1384030976 30826169}

func (*Filetime) Nanoseconds

func (ft *Filetime) Nanoseconds() int64

Nanoseconds returns Filetime ft in nanoseconds since Epoch (00:00:00 UTC, January 1, 1970).

Example
package main

import (
	"fmt"
	"time"

	"github.com/bodgit/windows"
)

func main() { //nolint:nosnakecase
	ft := windows.Filetime{
		1384030976,
		30826169,
	}

	fmt.Println(time.Unix(0, ft.Nanoseconds()).UTC())
}
Output:

2020-07-20 17:15:10 +0000 UTC

Jump to

Keyboard shortcuts

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