running gofmt on sources, and removing iconv LDFLAG on linux

This commit is contained in:
Donovan Jimenez 2013-06-27 16:56:58 -04:00
parent 76220410e9
commit c6169bab90
3 changed files with 11 additions and 12 deletions

View File

@ -1,9 +1,8 @@
package iconv package iconv
/* /*
#cgo darwin LDFLAGS: -liconv #cgo darwin LDFLAGS: -liconv
#cgo freebsd LDFLAGS: -liconv #cgo freebsd LDFLAGS: -liconv
#cgo linux LDFLAGS: -liconv
#cgo windows LDFLAGS: -liconv #cgo windows LDFLAGS: -liconv
#include <stdlib.h> #include <stdlib.h>
#include <iconv.h> #include <iconv.h>

View File

@ -1,10 +1,10 @@
package main package main
import ( import (
"encoding/hex" "encoding/hex"
"io/ioutil"
"iconv"
"fmt" "fmt"
"iconv"
"io/ioutil"
"os" "os"
) )
@ -12,7 +12,7 @@ func main() {
// read bytes from sample.utf8 // read bytes from sample.utf8
utf8Bytes, err := ioutil.ReadFile("sample.utf8") utf8Bytes, err := ioutil.ReadFile("sample.utf8")
if (err != nil) { if err != nil {
fmt.Println("Could not open 'sample.utf8': ", err) fmt.Println("Could not open 'sample.utf8': ", err)
} }
@ -57,7 +57,7 @@ func main() {
fmt.Println("ebcdic-us was properly converted to utf-8 by iconv.ConvertString") fmt.Println("ebcdic-us was properly converted to utf-8 by iconv.ConvertString")
} }
testBuffer := make([]byte, len(ebcdicBytes) * 2) testBuffer := make([]byte, len(ebcdicBytes)*2)
// convert from ebdic bytes to utf-8 bytes // convert from ebdic bytes to utf-8 bytes
bytesRead, bytesWritten, err := iconv.Convert(ebcdicBytes, testBuffer, "ebcdic-us", "utf-8") bytesRead, bytesWritten, err := iconv.Convert(ebcdicBytes, testBuffer, "ebcdic-us", "utf-8")
@ -78,8 +78,8 @@ func main() {
} }
// test iconv.Reader // test iconv.Reader
utf8File,_ := os.Open("sample.utf8", os.O_RDONLY, 0) utf8File, _ := os.Open("sample.utf8")
utf8Reader,_ := iconv.NewReader(utf8File, "utf-8", "ebcdic-us") utf8Reader, _ := iconv.NewReader(utf8File, "utf-8", "ebcdic-us")
bytesRead, err = utf8Reader.Read(testBuffer) bytesRead, err = utf8Reader.Read(testBuffer)
if err != nil || bytesRead != len(ebcdicBytes) { if err != nil || bytesRead != len(ebcdicBytes) {
@ -88,8 +88,8 @@ func main() {
fmt.Println("utf8 was property converted to ebcdic-us by iconv.Reader") fmt.Println("utf8 was property converted to ebcdic-us by iconv.Reader")
} }
ebcdicFile,_ := os.Open("sample.ebcdic-us", os.O_RDONLY, 0) ebcdicFile, _ := os.Open("sample.ebcdic-us")
ebcdicReader,_ := iconv.NewReader(ebcdicFile, "ebcdic-us", "utf-8") ebcdicReader, _ := iconv.NewReader(ebcdicFile, "ebcdic-us", "utf-8")
bytesRead, err = ebcdicReader.Read(testBuffer) bytesRead, err = ebcdicReader.Read(testBuffer)
if err != nil || bytesRead != len(utf8Bytes) { if err != nil || bytesRead != len(utf8Bytes) {

View File

@ -36,7 +36,7 @@ func NewWriterFromConverter(destination io.Writer, converter *Converter) (writer
} }
func (this *Writer) emptyBuffer() { func (this *Writer) emptyBuffer() {
// write new data out of buffer // write new data out of buffer
bytesWritten, err := this.destination.Write(this.buffer[this.readPos:this.writePos]) bytesWritten, err := this.destination.Write(this.buffer[this.readPos:this.writePos])
// update read position // update read position