binaryop

package
v0.5.44 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 10 Imported by: 0

README

サンプルリスト

このディレクトリには以下のサンプルがあります。

file example name note
read.go binaryop_read バイナリを読み込むサンプルです
write.go binaryop_write バイナリを書き込むサンプルです
binary_byteorder.go binaryop_byteorder encoding/binary パッケージを用いて Go におけるバイトオーダーの確認をするサンプルです.
mapstruct.go binaryop_mapping 構造体にバイナリデータをマッピングするサンプルです
struct_read_write.go binaryop_struct_read_write 構造体をバイナリにパックし、それをバイナリとして書き出すサンプルです
readwrite/binary_readwrite.go binaryop_readwrite binary パッケージの Read/Write を利用してエンディアン指定でデータを読み込むサンプルです

Documentation

Overview

Package binaryop -- encoding/binary パッケージについてのサンプルが配置されているパッケージです。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteOrder

func ByteOrder() error

ByteOrder -- encoding/binary パッケージを用いて Go におけるバイトオーダーの確認をするサンプルです.

func MapStruct

func MapStruct() error

MapStruct は、構造体にバイナリデータをマッピングするサンプルです.

func NativeEndian added in v0.5.43

func NativeEndian() error

NativeEndian は、binary.NativeEndian のサンプルです。

encoding/binary には、バイトオーダーを扱う3つの変数が定義されている。

  • binary.BigEndian : 最上位バイトから順に格納(ネットワークバイトオーダーとも呼ばれる)
  • binary.LittleEndian : 最下位バイトから順に格納(x86/x86-64系CPUの標準)
  • binary.NativeEndian : 実行環境のCPUに合わせたバイトオーダー

昨今のデスクトップ・サーバー向けCPU(x86/x86-64)はリトルエンディアンが標準であり、 ARMもiOS/Androidを含む多くの環境でリトルエンディアンモードで動作する。 そのため、NativeEndianはほぼリトルエンディアンと同義になるケースが多い。

NativeEndianの主な用途は、ローカルIPC(共有メモリ・パイプ等)のように 送受信が同一ホスト内で完結し、エンディアンを意識せずに記述したい場面で有用となる。 ネットワーク通信ではBigEndian(ネットワークバイトオーダー)を明示するのが原則。

REFERENCES

func NewRegister

func NewRegister() mapping.Register

NewRegister -- このパッケージ用のサンプルを登録する mapping.Register を生成します。

func Read

func Read() error

Read は、バイナリを読み込むサンプルです.

func StructReadWrite added in v0.5.1

func StructReadWrite() error

StructReadWrite は、構造体をバイナリにパックし、それをバイナリとして書き出すサンプルです.

REFERENCES

func Write

func Write() error

Write は、バイナリを書き込むサンプルです.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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