Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/generate-fix/internal/helpers.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

package internal

import (
Expand Down
24 changes: 24 additions & 0 deletions cmd/generate-fix/internal/helpers_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// +build windows

package internal

import (
"os"
"path/filepath"
"strings"
)

// getImportPathRoot returns the root path to use in import statements.
// The root path is determined by stripping "$GOPATH/src/" from the current
// working directory. For example, when generating code within the QuickFIX/Go
// source tree, the returned root path will be "github.com/quickfixgo/quickfix".
func getImportPathRoot() string {
pwd, err := os.Getwd()
if err != nil {
panic(err)
}
//goSrcPath := `C:\Users\Administrator\go\src\`
goSrcPath := filepath.Join(os.Getenv("USERPROFILE"), "Go", "src")
importPathRoot := filepath.ToSlash(strings.Replace(pwd, goSrcPath, "", 1))
return strings.TrimLeft(importPathRoot, "/")
}
10 changes: 10 additions & 0 deletions cmd/generate-fix/internal/helpers_windows_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package internal

import (
"fmt"
"testing"
)

func TestGetImportPathRoot(t *testing.T) {
fmt.Println("this is import :", getImportPathRoot())
}