草庐IT

write_pdf

全部标签

go - 我是否对 "How to Write Go Code"示例中 Go 工作区中的 git 存储库结构感到困惑?

我对HowtoWriteGoCode有两点困惑文章。它们可能是文章中的错误,或者我可能只是忽略了重点。在描述典型工作区的结构时,文章说Thesrcsubdirectorytypicallycontainsmultipleversioncontrolrepositories(suchasforGitorMercurial)thattrackthedevelopmentofoneormoresourcepackages.文章中的第一个示例工作区与此描述相匹配,有2个文件夹代表存储库(github.com/golang/example/和golang.org/x/image/),每一个在其正

unit-testing - 单元测试 os.File.Write 调用

我想对调用os.File.Write()的函数进行单元测试,并希望达到100%的覆盖率。此函数返回n和一个错误。引发错误很容易。我只需要关闭文件。我怎样才能不引起写入错误和写入数据长度的值n不同?看起来我应该创建一个虚拟的os.File,我可以在上面控制返回的错误。不幸的是,os.File不是一个接口(interface)。编辑:根据PeterOS的回答,仔细检查文档后,Write()方法,是否为io.Writer或io.File如果err为nil,将始终返回写入的slice的长度。结果,看来我的问题毫无意义。我学到了一些重要的东西,谢谢。我有一些代码要清理。附带说明一下,我对100%

go - fatal error : concurrent map read and map write

fatalerror:concurrentmapreadandmapwritegoroutine5065809[running]:runtime.throw(0x6b4281,0x21)/usr/local/go/src/runtime/panic.go:566+0x95fp=0xc420c05670sp=0xc420c05650runtime.mapaccess1_faststr(0x65ea20,0xc420015020,0xc42178ea8e,0x16,0x0)/usr/local/go/src/runtime/hashmap_fast.go:201+0x4f3fp=0xc42

pdf - 在 goPdf 中使用 Google Noto 字体

我正在尝试使用这个GoogleNotofont,但当我打印为pdf时,我看到的只是正方形。有谁知道如何将此字体添加到goPdf? 最佳答案 gopdf好像支持嵌入字体:https://godoc.org/github.com/signintech/gopdf#GoPdf.AddTTFFont 关于pdf-在goPdf中使用GoogleNoto字体,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/que

go - 运行 dep 时出错确保 : Grouped write of manifest, 锁和 vendor :无法统计 VerifyVendor 声称存在的文件

运行depensure时出现以下错误:Groupedwriteofmanifest,lockandvendor:couldnotstatfilethatVerifyVendorclaimedexisted:stat"pathtopackageinsidevendor":nosuchfileordirectory这是我的Gopkg.toml:[[constraint]]name="github.com/PuerkitoBio/goquery"version="1.5.0"[[constraint]]branch="master"name="github.com/auth0-communi

pdf - 如何通过gopdf将文本数据打印成pdf?

我尝试过的:vardatastringdata="Line1\n"+"Line2\n"+"Line3\n"+"Line4"//It'sgotfromDBwhichsavedbybrdata.pdf.SetFont("wts11","",14)pdf.SetX(100)pdf.SetY(200)pdf.Text(data)结果:pdf显示:所有其他打印数据都消失了。也许它无法解析.连变pdf.Text(data)至pdf.Cell(nil,text),也是一样的结果。引用:https://github.com/signintech/gopdf类似问题:https://github.com

sockets - golang write net conn 不返回错误但是socket的另一端收不到数据

//onlyDatafunc(self*Packet)WriteData(wio.Writer)error{n:=len(self.Data)data:=self.Data[0:n]forn>0{wn,err:=w.Write(data)data=data[wn:n]n-=wniferr!=nil{returnerr}}returnnil}当我用net.Conn(由net.Dial("tcp")创建)调用WriteData函数时,它返回nil,但套接字的另一个端口有时无法接收到发送的数据。似乎连接中断了,但是w.Write仍然没有错误地返回。在我看来,当此套接字的另一端未收到数据包时,

go - binary.Write() 字节排序不适用于 []byte

packagemainimport("encoding/binary""fmt""bytes")funcmain(){b:=new(bytes.Buffer)c:=new(bytes.Buffer)binary.Write(b,binary.LittleEndian,[]byte{0,1})binary.Write(b,binary.BigEndian,[]byte{0,1})binary.Write(c,binary.LittleEndian,uint16(256))binary.Write(c,binary.BigEndian,uint16(256))fmt.Println(b.B

go - 在 Golang 中,为什么 conn.Write tcp 响应为空?

我有一个读取文件的tcp服务器,该文件将文件内容发送到客户端。“status.txt”文件仅包含一个bool值。当我curl时,这显示true(带有前导空格)。dat,err:=ioutil.ReadFile("./status.txt")conn.Write([]byte(""+string(dat)))而此代码导致curl:(52)Emptyreplyfromserver。conn.Write([]byte(string(dat)))知道为什么会这样吗?我不想填充我的响应字符串。 最佳答案 如果您不使用HTTP协议(protoc

go - 为什么即使有锁,GO 也会出现 'concurrent map writes' panic ?

当尝试将此结构与多个goroutine一起使用时,有时我会遇到以下错误之一:fatalerror:并发映射读取和映射写入或并发映射写入看完thisthread我确保在构造函数中返回一个引用,并将一个引用传递给接收者。使用它的完整代码在thisgithubrepo中typeconcurrentStoragestruct{sync.Mutexdomainstringurlsmap[url.URL]bool}funcnewConcurrentStorage(dstring)*concurrentStorage{return&concurrentStorage{domain:d,urls:ma