Skip to content

Conversation

abheyshah
Copy link

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
Copy link
Contributor

cbusbey commented Feb 7, 2018

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
Copy link
Author

abheyshah commented Feb 8, 2018 via email

@Moataz-E
Copy link

Moataz-E commented Feb 8, 2018

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"
)

Copy link

@Moataz-E Moataz-E left a comment

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.

Copy link

@Moataz-E Moataz-E left a comment

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
Copy link
Contributor

cbusbey commented Feb 8, 2018

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

@cbusbey cbusbey reopened this Feb 8, 2018
@cbusbey
Copy link
Contributor

cbusbey commented Feb 27, 2018

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