bomtrim

package module
v0.0.0-...-5aa8ce4 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 1 Imported by: 0

README

bomtrim

A tiny utility that removes byte order marks so you don't have to!

Byte order marks are special unicode characters prefixed to text files, such as \uFEFF.


Install

GOPROXY=direct go get -u github.com/Kindred87/bomtrim

Quickstart

package main

import (
    "encoding/csv"
    "fmt"
    "os"

    "github.com/Kindred87/bomtrim"
)

func main() {
    fi, err := os.Open("foo.csv")
    if err != nil {
        log.Fatalf("error while reading foo.csv: %s", err.Error())
    }

    defer fi.Close()

    reader := csv.NewReader(fi)

    firstRow, err := reader.Read()
	if err != nil {
		log.Fatalf("error while reading first row in %s: %s", fi.Name(), err.Error())
	}

    fmt.Printf("Before trimming: %#v\n", firstRow)

    firstRow = bomtrim.FirstIndex(firstRow)

    fmt.Printf("After trimming: %#v\n", firstRow)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstIndex

func FirstIndex(record []string) []string

FirstIndex removes the BOM from the first index of the given slice.

func String

func String(s string) string

String removes the BOM from the given string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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