• Stars
    star
    305
  • Rank 136,879 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A golang source code scanner, this time in sql :)

GoQL

A query language, over Go code, in Go!

Build Status Coverage Status GoDoc Go Report Card

This package is under heavy development, anything may change!

This is a golang sql driver, to interact with Go code. currently only select is possible, but the insert/update/delete is in todo list.

Usage

like any other sql driver in golang, just import the goql package in your code :

package main

import (
	"database/sql"
	"fmt"
	"log"

	_ "github.com/fzerorubigd/goql"
	"github.com/fzerorubigd/goql/astdata"
)

func main() {
	// open the net/http package
	con, err := sql.Open("goql", "net/http")
	if err != nil {
		log.Fatal(err)
	}
	defer con.Close()

	rows, err := con.Query("SELECT name, receiver, def FROM funcs")
	if err != nil {
		log.Fatal(err)
	}

	for rows.Next() {
		var (
			name string
			rec  sql.NullString
			def  astdata.Definition
		)
		rows.Scan(&name, &rec, &def)
		if rec.Valid {
			name = rec.String + "." + name
		}
		fmt.Printf("\nfunc %s , definition : %s", name, def.String())
	}

}

Also there is an example command line is available for more advanced usage in cmd/goql by running go get -u github.com/fzerorubigd/goql/... the binary is available in your GOBIN directory. you can run query against any installed package in your GOPATH via this tool.

List of supported tables and fields are available in docs/table

there is one special type called definition. this type is printed as string, but one can use functions to handle special queries. list of supported functions are available at docs/functions

also its possible to add new tables/fields/functions using plugins. an example plugin is available at plugin/goqlimport

currently only supported query is select , with where,order and limit some example query :

select * from files where the docs is not null
select * from funcs where def = 'func()' and exported
select * from consts order by name desc limit 10, 10
select * from vars where is_struct(def) and name like 's%'
select * from types where is_map(def) and map_key(def) = 'string'
select * from imports where canonical = 'ctx'

Demo

asciicast

TODO

  • Write (more) documentation
  • UPDATE/INSERT/DELETE support (Yes, code generation with sql :) )

More Repositories

1

persian-fonts-linux

Persian fonts installer for linux
Shell
199
star
2

tmass

tmux session manager written in golang
Go
78
star
3

bitacoin

Go
35
star
4

go0r

A simple ssh honeypot in golang
Go
34
star
5

engine

My base for my web projects
Go
30
star
6

zacman

zacman, a simple zsh package manager in go
Go
27
star
7

plf

Ψ³ΩˆΨ§Ω„Ψ§Ψͺ Ω…ΨͺΨ―Ψ§ΩˆΩ„ Ω„ΫŒΩ†ΩˆΪ©Ψ³ΫŒ برای ΨͺΨ§Ψ²Ω‡ Ϊ©Ψ§Ψ±Ω‡Ψ§
CSS
25
star
8

redimock

[WIP] redis mock library in tcp level
Go
22
star
9

awesome-golang-jobs-iran

A curated list of companies using Golang in Iran
Go
20
star
10

slides

My presentation about golang
Go
17
star
11

block

two model of try/catch like mechanism for golang (Don't panic, it's not about panic :) )
Go
14
star
12

humanize

ast representation of go package, in human :) friendly form
Go
14
star
13

connect-party-game

Connect party game in persian
14
star
14

chapar

Yet another worker system for golang, NOT READY, just testing
Go
10
star
15

docker-cowproxy

Dockerized version of cow https://github.com/cyfdecyf/cow
Shell
10
star
16

clictx

Go
8
star
17

emailvalidator

An email validation library, without regex
Go
8
star
18

didebaan

Go
7
star
19

pmg

Persian mafia game robot
PHP
7
star
20

gozin

Dynamic select for golang
Go
6
star
21

gobgg

Boardgamegeek API for Golang
Go
6
star
22

smtpd

Go
5
star
23

dotfiles

My dotfile, just for personal use, use it if you like.
Emacs Lisp
5
star
24

kitchen

A simple bootstrap for my own web projects
Go
5
star
25

mohajer

Mohajer, go migration tool
Go
4
star
26

netdata-docker

Shell
4
star
27

3d-qr-code

Convert a text into a qrcode stl file ready to 3d print
Go
4
star
28

fzerorubigd.github.io

My blog, powered by hugo
HTML
3
star
29

TheFirstPlayer

A meta game to select first player in a board game in a game night, with campaign mode.
3
star
30

cardx

Go
3
star
31

archlinux-packages

my Archlinux package in AUR
Shell
3
star
32

bit-template

A Board game insert Toolkit template with makefile and CI/CD to release in Github
OpenSCAD
3
star
33

multilock

A simple multi lock for golang
Go
2
star
34

vimp

My vim configuration using vim 8 plugin system
Vim Script
2
star
35

expand

A simple string expander in golang
Go
2
star
36

flynn-nats

A flynn app to deploy nats on a flynn cluster, currently using one node
Shell
2
star
37

phpthumb-service-provider

PHPThumb service provider for silex
PHP
2
star
38

baseimage

my project base image as a vagrant box its based on https://github.com/phusion/baseimage-docker/ and I changed it alot to reflect my needs. use a fork if you want to use this repository
Python
2
star
39

annotate

Go
1
star
40

elbot-old

Just for fun.
PHP
1
star
41

elosort

Go
1
star
42

tehlug-tdd

Tehlug tdd
PHP
1
star
43

minify

minify module
PHP
1
star
44

bg-insert

Random board game insert, Just for fun
OpenSCAD
1
star
45

eventual

A simple event system with channels
Go
1
star
46

chapar-examples

Go
1
star
47

docker-pgbouncer

pgbouncer container for docker
Shell
1
star
48

imporder

Go
1
star
49

dohd

A simple doh to dns server
Go
1
star
50

protobuf

personal prootbuf stuff, not usable for anyone (yet?)
Go
1
star
51

builder

simple builder machne for internal use
Go
1
star
52

request-proxy

Proxy a request to another server
PHP
1
star
53

my-docker-build

My docker build
Shell
1
star
54

docker-tinydns

dockerized tinydns plus vegadns
Shell
1
star
55

tiletum-insert

tiletum-insert
OpenSCAD
1
star
56

bgg-hotness

Track BGG Hotness in google sheet
Go
1
star
57

ecal

Python
1
star
58

scout-oink

Insert for SCOUT from Oink games
OpenSCAD
1
star