-
Notifications
You must be signed in to change notification settings - Fork 316
added support for code generation on windows #317
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
added support for code generation on windows #317
Conversation
This should be unnecessary if your GOPATH is correctly set up. For details on GOPATH |
Hi, My GOPATH is (correctly) set. Apologies if the code I submitted implied
that was the main issue. The real issue is that windows uses backslashes as
file separator. So the generated imports are like this "github.com
\quickfixgo/tag".
And \q is an unknown escape sequence. Appreciate you may not have immediate
access to a windows machine to verify the issue and integrate the commit,
but perhaps keep it as an open issue?
Using your original code I get:
C:\Users\Abhey\Go\src\github.com\quickfixgo>set GO
GOPATH=C:\Users\Abhey\Go
GOROOT=C:\Go\
C:\Users\Abhey\Go\src\github.com\quickfixgo>generate-fix
quickfix\spec\FIX50.xml
Error parsing fix50/tradingsessionlistrequest/TradingSessionListRequest.generated.go:
8:14: unknown escape sequence (and 3 more errors)
Error parsing fix50/liststatusrequest/ListStatusRequest.generated.go: 8:14:
unknown escape sequence (and 2 more errors)
Error parsing fix50/tradingsessionstatusrequest/TradingSessionStatusRequest.generated.go:
8:14: unknown escape sequence (and 3 more errors)
...
C:\Users\Abhey\Go\src\github.com\quickfixgo>type
fix50\tradingsessionlistrequest\TradingSessionListRequest.generated.go
package tradingsessionlistrequest
import (
"github.com\quickfixgo/tag"
"github.com/quickfixgo/quickfix"
)
//TradingSessionListRequest is the fix50 TradingSessionListRequest type,
MsgType = BI
type TradingSessionListRequest struct {
...
…On Wed, Feb 7, 2018 at 1:32 PM, Chris Busbey ***@***.***> wrote:
This should be unnecessary if your GOPATH is correctly set up. For details
on GOPATH
https://github.com/golang/go/wiki/GOPATH
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#317 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AVlyzdOu1LYnrbc3DHhPqcOICcqE0dGzks5tSaXsgaJpZM4RleXZ>
.
|
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:
|
There was a problem hiding this 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.
There was a problem hiding this 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, "/")
}
@Moataz-E I think you hit on a more elegant solution |
handled by #323 |
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.