Skip to content

Commit

Permalink
rm unnecessary go sub-packages
Browse files Browse the repository at this point in the history
  • Loading branch information
asg017 committed Aug 1, 2022
1 parent 8c7431b commit 8e84504
Show file tree
Hide file tree
Showing 16 changed files with 531 additions and 694 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sqlite/* linguist-vendored
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,25 @@ $(TARGET_LOADABLE): $(shell find . -type f -name '*.go')
$(GO_BUILD_CGO_CFLAGS) go build \
-buildmode=c-shared -o $@ -tags="shared" \
$(GO_BUILD_LDFLAGS) \
shared.go
.

$(TARGET_LOADABLE_NO_NET): $(shell find . -type f -name '*.go')
$(GO_BUILD_NO_NET_CGO_CFLAGS) go build \
-buildmode=c-shared -o $@ -tags="shared" \
$(GO_BUILD_NO_NET) \
shared.go
$(GO_BUILD_NO_NET_LDFLAGS) \
.

$(TARGET_OBJ): $(shell find . -type f -name '*.go')
$(GO_BUILD_CGO_CFLAGS) CGO_ENABLED=1 go build -buildmode=c-archive \
$(GO_BUILD_LDFLAGS) \
-o $@ shared.go
-o $@ .

# framework stuff is needed bc https://github.com/golang/go/issues/42459#issuecomment-896089738
$(TARGET_SQLITE3): $(TARGET_OBJ) dist/sqlite3-extra.c sqlite/shell.c
gcc \
-framework CoreFoundation -framework Security \
dist/sqlite3-extra.c sqlite/shell.c $(TARGET_OBJ) \
-L. -I./ \
-L. -Isqlite \
-DSQLITE_EXTRA_INIT=core_init -DSQLITE3_INIT_FN=sqlite3_http_init \
-o $@

Expand All @@ -85,7 +85,7 @@ httpbin:
clean:
rm dist/*

test:
test: $(TARGET_LOADABLE) $(TARGET_LOADABLE_NO_NET)
python3 test.py

test-watch:
Expand Down
13 changes: 12 additions & 1 deletion cookies/cookies.go → cookies.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cookies
package main

import (
"encoding/json"
Expand All @@ -7,6 +7,9 @@ import (
"go.riyazali.net/sqlite"
)

// http_cookies(name1, value2, ...)
// Returns a JSON object where keys nameN, and vlaues are valueN
// Meant as a parameter for request functions like http_get and http_get_body
type CookiesFunc struct{}

func (*CookiesFunc) Deterministic() bool { return true }
Expand All @@ -30,3 +33,11 @@ func (*CookiesFunc) Apply(c *sqlite.Context, values ...sqlite.Value) {
c.ResultText(string(txt))
}
}

func RegisterCookies(api *sqlite.ExtensionApi) error {
if err := api.CreateFunction("http_cookies", &CookiesFunc{}); err != nil {
return err
}

return nil
}
26 changes: 0 additions & 26 deletions cookies/register.go

This file was deleted.

Loading

0 comments on commit 8e84504

Please sign in to comment.