Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

feat: Support large structs #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Goopfile

This file was deleted.

3 changes: 0 additions & 3 deletions Goopfile.lock

This file was deleted.

5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ to compare different structs and as the result - to understand
and remember alignment rules.

## Installing
To install correct versions of dependencies
[Goop dependency manager](https://github.com/nitrous-io/goop) should be used.
```bash
go get github.com/gophergala/golang-sizeof.tips
cd github.com/gophergala/golang-sizeof.tips
goop install
goop go build -o ./server
go build -o ./server
```
You may also install via simple `go get` by your own risk.

Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package app

import "github.com/gophergala/golang-sizeof.tips/internal/log"
import "github.com/tyranron/golang-sizeof.tips/internal/log"

var appLog log.Logger

Expand Down
14 changes: 13 additions & 1 deletion app/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,30 @@ import (
"net/http"
"strings"

"github.com/gophergala/golang-sizeof.tips/internal/parser"
"github.com/tyranron/golang-sizeof.tips/internal/parser"
)

const exampleCode = `// Sample code
struct {
a string
b bool
c string
d string
}
`

func discoverHandler(w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil {
toRender := &struct {
Code string
Result *viewData
Error string
}{Code: exampleCode}
toRender.Error = err.Error()
templates["index"].ExecuteTemplate(w, "base", toRender)
return
}

code := parseCodeRequestParam(r.FormValue("t"))
if code == "" {
code = exampleCode
Expand Down
2 changes: 1 addition & 1 deletion app/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"runtime"
"strings"

"github.com/gophergala/golang-sizeof.tips/internal/bindata/static"
"github.com/tyranron/golang-sizeof.tips/internal/bindata/static"
)

func bindHttpHandlers() {
Expand Down
2 changes: 1 addition & 1 deletion app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"syscall"
"time"

"github.com/gophergala/golang-sizeof.tips/internal/log"
"github.com/tyranron/golang-sizeof.tips/internal/log"

daemon "github.com/tyranron/daemonigo"
)
Expand Down
2 changes: 1 addition & 1 deletion app/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package app
import (
"html/template"

bin "github.com/gophergala/golang-sizeof.tips/internal/bindata/templates"
bin "github.com/tyranron/golang-sizeof.tips/internal/bindata/templates"
)

const templatesDir = "templs/"
Expand Down
3 changes: 3 additions & 0 deletions generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

//go:generate go-bindata -o internal/bindata/templates/bindata.go -pkg templates templs/...
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/tyranron/golang-sizeof.tips

go 1.13

require (
github.com/alecthomas/log4go v0.0.0-20180109082532-d146e6b86faa
github.com/elazarl/go-bindata-assetfs v1.0.0
github.com/jteeuwen/go-bindata v3.0.7+incompatible // indirect
github.com/tyranron/daemonigo v0.3.1
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/alecthomas/log4go v0.0.0-20180109082532-d146e6b86faa h1:0zdYOLyuQ3TWIgWNgEH+LnmZNMmkO1ze3wriQt093Mk=
github.com/alecthomas/log4go v0.0.0-20180109082532-d146e6b86faa/go.mod h1:iCVmQ9g4TfaRX5m5jq5sXY7RXYWPv9/PynM/GocbG3w=
github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
github.com/jteeuwen/go-bindata v3.0.7+incompatible h1:91Uy4d9SYVr1kyTJ15wJsog+esAZZl7JmEfTkwmhJts=
github.com/jteeuwen/go-bindata v3.0.7+incompatible/go.mod h1:JVvhzYOiGBnFSYRyV00iY8q7/0PThjIYav1p9h5dmKs=
github.com/tyranron/daemonigo v0.3.1 h1:kLt7oKl2AceLdPl6qaXOYQZM4ZZLhT9jWrZa02iq2PQ=
github.com/tyranron/daemonigo v0.3.1/go.mod h1:tXUGvLFtBWBCpYfzgvLNuHZ4NhuwSjyNcs4gsXWZw8k=
187 changes: 22 additions & 165 deletions internal/bindata/templates/bindata.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/log/filelog/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"sync"
"time"

log "code.google.com/p/log4go"
log "github.com/alecthomas/log4go"
)

// Day format for comparing files changed time during daily log rotation.
Expand Down
5 changes: 2 additions & 3 deletions internal/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"fmt"
"os"

"github.com/gophergala/golang-sizeof.tips/internal/log/filelog"

l4g "code.google.com/p/log4go"
l4g "github.com/alecthomas/log4go"
"github.com/tyranron/golang-sizeof.tips/internal/log/filelog"
)

// Relative path (from application root) to file
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"os"

"github.com/gophergala/golang-sizeof.tips/app"
"github.com/tyranron/golang-sizeof.tips/app"
)

func main() {
Expand Down
6 changes: 5 additions & 1 deletion templs/index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/golang");
$("#go").click(function() {
window.location.href = '?t=' + window.btoa(editor.getSession().getValue())
$("#t").val(window.btoa(editor.getSession().getValue()));
$("#form-id").submit();
});
});
</script>
<form id="form-id" action="/" method="POST">
<input type="hidden" id="t" name="t">
</form>
{{ end }}