Showing
3 changed files
with
64 additions
and
27 deletions
... | @@ -5,4 +5,14 @@ go 1.17 | ... | @@ -5,4 +5,14 @@ go 1.17 |
5 | require ( | 5 | require ( |
6 | github.com/caarlos0/env/v6 v6.9.1 // indirect | 6 | github.com/caarlos0/env/v6 v6.9.1 // indirect |
7 | github.com/joho/godotenv v1.4.0 // indirect | 7 | github.com/joho/godotenv v1.4.0 // indirect |
8 | + github.com/labstack/echo/v4 v4.7.2 // indirect | ||
9 | + github.com/labstack/gommon v0.3.1 // indirect | ||
10 | + github.com/mattn/go-colorable v0.1.11 // indirect | ||
11 | + github.com/mattn/go-isatty v0.0.14 // indirect | ||
12 | + github.com/valyala/bytebufferpool v1.0.0 // indirect | ||
13 | + github.com/valyala/fasttemplate v1.2.1 // indirect | ||
14 | + golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect | ||
15 | + golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect | ||
16 | + golang.org/x/sys v0.0.0-20211103235746-7861aae1554b // indirect | ||
17 | + golang.org/x/text v0.3.7 // indirect | ||
8 | ) | 18 | ) | ... | ... |
1 | github.com/caarlos0/env/v6 v6.9.1 h1:zOkkjM0F6ltnQ5eBX6IPI41UP/KDGEK7rRPwGCNos8k= | 1 | github.com/caarlos0/env/v6 v6.9.1 h1:zOkkjM0F6ltnQ5eBX6IPI41UP/KDGEK7rRPwGCNos8k= |
2 | github.com/caarlos0/env/v6 v6.9.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc= | 2 | github.com/caarlos0/env/v6 v6.9.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc= |
3 | +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
4 | +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
3 | github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg= | 5 | github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg= |
4 | github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= | 6 | github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= |
7 | +github.com/labstack/echo/v4 v4.7.2 h1:Kv2/p8OaQ+M6Ex4eGimg9b9e6icoxA42JSlOR3msKtI= | ||
8 | +github.com/labstack/echo/v4 v4.7.2/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks= | ||
9 | +github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o= | ||
10 | +github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= | ||
11 | +github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs= | ||
12 | +github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= | ||
13 | +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= | ||
14 | +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= | ||
15 | +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
16 | +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
17 | +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
18 | +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= | ||
19 | +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= | ||
20 | +github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4= | ||
21 | +github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= | ||
22 | +golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= | ||
23 | +golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= | ||
24 | +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY= | ||
25 | +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | ||
26 | +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
27 | +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
28 | +golang.org/x/sys v0.0.0-20211103235746-7861aae1554b h1:1VkfZQv42XQlA/jchYumAnv1UPo6RgF9rJFkTgZIxO4= | ||
29 | +golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
30 | +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= | ||
31 | +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | ||
32 | +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
33 | +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||
34 | +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ... | ... |
1 | package main | 1 | package main |
2 | 2 | ||
3 | -import ( | 3 | +import "github.com/labstack/echo/v4" |
4 | - "fmt" | ||
5 | - "io/ioutil" | ||
6 | - "joongna/config" | ||
7 | - "log" | ||
8 | - "net/http" | ||
9 | - url2 "net/url" | ||
10 | -) | ||
11 | 4 | ||
12 | func main() { | 5 | func main() { |
13 | - keyword := "m1 pro 맥북 프로 16인치" | 6 | + //keyword := "m1 pro 맥북 프로 16인치" |
14 | - encText := url2.QueryEscape("중고나라" + keyword) | 7 | + //encText := url2.QueryEscape("중고나라" + keyword) |
15 | - url := "https://openapi.naver.com/v1/search/cafearticle.json?query=" + encText + "&sort=sim" | 8 | + //url := "https://openapi.naver.com/v1/search/cafearticle.json?query=" + encText + "&sort=sim" |
9 | + // | ||
10 | + //req, err := http.NewRequest("GET", url, nil) | ||
11 | + //if err != nil { | ||
12 | + // log.Fatal(err) | ||
13 | + //} | ||
14 | + //req.Header.Add("X-Naver-Client-Id", config.Cfg.Secret.CLIENTID) | ||
15 | + //req.Header.Add("X-Naver-Client-Secret", config.Cfg.Secret.CLIENTSECRET) | ||
16 | + // | ||
17 | + //client := &http.Client{} | ||
18 | + //resp, err := client.Do(req) | ||
19 | + //if err != nil { | ||
20 | + // log.Fatal(err) | ||
21 | + //} | ||
22 | + //defer resp.Body.Close() | ||
23 | + // | ||
24 | + //bytes, _ := ioutil.ReadAll(resp.Body) | ||
25 | + //str := string(bytes) | ||
26 | + //fmt.Println(str) | ||
16 | 27 | ||
17 | - req, err := http.NewRequest("GET", url, nil) | 28 | + e := echo.New() |
18 | - if err != nil { | ||
19 | - log.Fatal(err) | ||
20 | - } | ||
21 | - req.Header.Add("X-Naver-Client-Id", config.Cfg.Secret.CLIENTID) | ||
22 | - req.Header.Add("X-Naver-Client-Secret", config.Cfg.Secret.CLIENTSECRET) | ||
23 | 29 | ||
24 | - client := &http.Client{} | 30 | + e.Logger.Fatal(e.Start(":8080")) |
25 | - resp, err := client.Do(req) | ||
26 | - if err != nil { | ||
27 | - log.Fatal(err) | ||
28 | - } | ||
29 | - defer resp.Body.Close() | ||
30 | - | ||
31 | - bytes, _ := ioutil.ReadAll(resp.Body) | ||
32 | - str := string(bytes) | ||
33 | - fmt.Println(str) | ||
34 | } | 31 | } | ... | ... |
-
Please register or login to post a comment