Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
seipan committed Dec 12, 2023
1 parent 0e9e5a3 commit cec10e0
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:
strategy:
matrix:
go-version: ['1.18', '1.19', '1.20', '1.21']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Build
run: go build -v ./...

- name: Test
run: go test -race -coverprofile=coverage.txt -covermode=atomic

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: golangci-lint
uses: reviewdog/action-golangci-lint@v2
60 changes: 60 additions & 0 deletions drill.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package drill

import (
"net/http"
"net/url"
)

type drill struct {
url *url.URL

method string
}

func new(urls string, mthd string) *drill {
parseurls, err := url.Parse(urls)
if err != nil {
panic(err)
}
return &drill{
url: parseurls,
method: mthd,
}
}

func Get(url string) {
client := new(url, "GET")
http.Get(client.url.String())
}

func Post(url string) {
client := new(url, "POST")
http.Post(client.url.String(), "", nil)
}

func Put(url string) {
client := new(url, "PUT")
r, err := http.NewRequest(client.method, client.url.String(), nil)
if err != nil {
panic(err)
}
http.DefaultClient.Do(r)
}

func Delete(url string) {
client := new(url, "DELETE")
r, err := http.NewRequest(client.method, client.url.String(), nil)
if err != nil {
panic(err)
}
http.DefaultClient.Do(r)
}

func Head(url string) {
client := new(url, "HEAD")
r, err := http.NewRequest(client.method, client.url.String(), nil)
if err != nil {
panic(err)
}
http.DefaultClient.Do(r)
}
1 change: 1 addition & 0 deletions drill_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package drill

0 comments on commit cec10e0

Please sign in to comment.