Skip to content

added support for code generation on windows#317

Closed
abheyshah wants to merge 1 commit into
quickfixgo:masterfrom
abheyshah:code-generation-support-for-windows
Closed

added support for code generation on windows#317
abheyshah wants to merge 1 commit into
quickfixgo:masterfrom
abheyshah:code-generation-support-for-windows

Conversation

@abheyshah

Copy link
Copy Markdown

Minor changes that permit code generation on windows and uses filepath in place of path. An initial prototype test function has been added but doesn't really do any validation and really needs a cross platform implementation.

@cbusbey

cbusbey commented Feb 7, 2018

Copy link
Copy Markdown
Contributor

This should be unnecessary if your GOPATH is correctly set up. For details on GOPATH

https://github.com/golang/go/wiki/GOPATH

@cbusbey cbusbey closed this Feb 7, 2018
@abheyshah

abheyshah commented Feb 8, 2018 via email

Copy link
Copy Markdown
Author

@Moataz-E

Moataz-E commented Feb 8, 2018

Copy link
Copy Markdown

I can confirm that I am facing the same issue on a windows machine. Trying abheyshah's version fixed the issue for me.

Previously, my generated FIX was throwing a lot of errors and looked like this:

import (
	"C:\Users\<my username>\work\code\go\src\github.com\quickfixgo\quickfix/tag"
	"github.com/quickfixgo/quickfix"
)

@Moataz-E Moataz-E left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment on line 20 of the helpers_windows.go file.

@Moataz-E Moataz-E left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a better version that maintains backward compatibility with the GOPATH env requirement and still works on windows:

func getImportPathRoot() string {
	pwd, err := os.Getwd()
	if err != nil {
		panic(err)
	}
	goSrcPath := filepath.Join(os.Getenv("GOPATH"), "src")
	importPathRoot := filepath.ToSlash(strings.Replace(pwd, goSrcPath, "", 1))
	return strings.TrimLeft(importPathRoot, "/")
}

@cbusbey

cbusbey commented Feb 8, 2018

Copy link
Copy Markdown
Contributor

@Moataz-E I think you hit on a more elegant solution

@cbusbey cbusbey reopened this Feb 8, 2018
@cbusbey

cbusbey commented Feb 27, 2018

Copy link
Copy Markdown
Contributor

handled by #323

@cbusbey cbusbey closed this Feb 27, 2018
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

Successfully merging this pull request may close these issues.

3 participants