Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README.md Go Documentation Flaw #289

Open
pathaugen opened this issue Jul 7, 2016 · 0 comments
Open

README.md Go Documentation Flaw #289

pathaugen opened this issue Jul 7, 2016 · 0 comments

Comments

@pathaugen
Copy link

Flaw in Go Documentation

This could be old documentation from an older version, but it no longer works and I'm including the reason and solution:

From the README.md


First download with go get -u github.com/miketheprogrammer/go-thrust/

package main

import (
    "github.com/miketheprogrammer/go-thrust/dispatcher"
    "github.com/miketheprogrammer/go-thrust/spawn"
    "github.com/miketheprogrammer/go-thrust/window"
)

func main() {
    spawn.Run()
    thrustWindow := window.NewWindow("http://breach.cc/", nil)
    thrustWindow.Show()
    thrustWindow.Maximize()
    thrustWindow.Focus()
    dispatcher.RunLoop()
}

Problem

thrustWindow := window.NewWindow("http://breach.cc/", nil)

window.NewWindow() does not accept string type for the first parameter, but a new struct: "Options"

window.go

type Options struct {
    RootUrl  string
    Size     SizeHW
    Title    string
    IconPath string
    HasFrame bool
    Session  *session.Session
}

commands.go

type SizeHW struct {
    Width  uint `json:"width,omitempty"`
    Height uint `json:"height,omitempty"`
}

By providing a struct for window.NewWindow() you can solve this issue.

Example Solution

import (
    "github.com/miketheprogrammer/go-thrust/lib/dispatcher"
    "github.com/miketheprogrammer/go-thrust/lib/spawn"
    "github.com/miketheprogrammer/go-thrust/lib/bindings/window"
    "github.com/miketheprogrammer/go-thrust/lib/commands" // NEW: Required struct SizeHW
)

func main() {
    spawn.Run()
    //thrustWindow := window.NewWindow("http://breach.cc/", nil) // OLD
    thrustSize := commands.SizeHW{Width:1024, Height: 768} // NEW: SizeHW struct
    thrustOptions := window.Options{RootUrl:"http://www.google.com/", Size: thrustSize} // NEW: Options struct
    thrustWindow := window.NewWindow(thrustOptions) // NEW: Using the options
    thrustWindow.Show()
    thrustWindow.Maximize()
    thrustWindow.Focus()
    dispatcher.RunLoop()
}

This is tested under Windows 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant