Skip to content

README.md Go Documentation Flaw #289

@pathaugen

Description

@pathaugen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions