added support for code generation on windows#317
Closed
abheyshah wants to merge 1 commit intoquickfixgo:masterfrom
Closed
added support for code generation on windows#317abheyshah wants to merge 1 commit intoquickfixgo:masterfrom
abheyshah wants to merge 1 commit intoquickfixgo:masterfrom
Conversation
Contributor
|
This should be unnecessary if your GOPATH is correctly set up. For details on GOPATH |
Author
|
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: |
Moataz-E
reviewed
Feb 8, 2018
Moataz-E
left a comment
There was a problem hiding this comment.
Remove comment on line 20 of the helpers_windows.go file.
Moataz-E
reviewed
Feb 8, 2018
Moataz-E
left a comment
There was a problem hiding this comment.
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, "/")
}
Contributor
|
@Moataz-E I think you hit on a more elegant solution |
Contributor
|
handled by #323 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.