## 边学边练
因为要爬个网站的图片就把代码整理一下做了一个简单的小库。
经历了从一个**main**到几个**func** 再到一个**package** ,????️学习如何写单元测试,再完善,最终到如何发布**[pkg.go.dev](https://pkg.go.dev/github.com/gitgitcode/alink?tab=doc)**
遇到了很多很多问题几乎就是一路google出来的代码,同时感觉还有很多不规范和使用错误的地方希望大家指正????。
[![Build Status](https://travis-ci.org/gitgitcode/alink.svg?branch=master)](https://travis-ci.org/gitgitcode/alink)
[![Coverage Status](https://coveralls.io/repos/github/gitgitcode/alink/badge.svg?branch=master)](https://coveralls.io/github/gitgitcode/alink?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/gitgitcode/alink)](https://goreportcard.com/report/github.com/gitgitcode/alink)
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/gitgitcode/alink?tab=doc)
- 安装 ```go get -u github.com/gitgitcode/alink```
- 简单例子
```go
package main
import (
"fmt"
"github.com/gitgitcode/alink"
"io/ioutil"
"net/http"
)
func main(){
rep,err := http.Get("https://studygolang.com")
if err != nil{
panic(err)
}
body,err:= ioutil.ReadAll(rep.Body)
if err !=nil{
panic(err)
}
title,err := alink.GetTitleWithByte(body)
if err !=nil{
panic(err)
}
fmt.Println(title)
img,err := alink.GetImgSrcWithByte(body)
if err !=nil{
panic(err)
}
//for _,v:=range *img{
fmt.Println( (*img)[0])
//}
//首页 - Go语言中文网 - Golang中文社区
//https://static.studygolang.com/static/img/logo.png
}
```
有疑问加站长微信联系(非本文作者)