Skip to content

fix(go): Correct Go module import paths - #2118

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
comeback01:fix/go-import-paths
Oct 28, 2025
Merged

fix(go): Correct Go module import paths#2118
seefs001 merged 1 commit into
QuantumNous:mainfrom
comeback01:fix/go-import-paths

Conversation

@comeback01

@comeback01 comeback01 commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

This PR (Pull Request) fixes the Go build errors that occurred after changing the repository URL.

Problem

The docker build command was failing with errors like:

package one-api/common is not in std

This was caused by an inconsistency between the module path defined in go.mod (github.com/QuantumNous/new-api) and the import paths used in the source code, which still referred to the old module name (one-api).

Solution

This change replaces all old import references ("one-api/...") with the new, module-compliant ones ("github.com/QuantumNous/new-api/...") across all Go files in the project.

Result

This resolves the build errors and allows the Docker image to be built successfully.

Summary by CodeRabbit

  • Chores
    • Updated module import paths for internal dependencies.

@coderabbitai

coderabbitai Bot commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Import paths in the controller file have been updated from local module aliases (one-api/...) to an external module path (github.com/QuantumNous/new-api/). No logic or functionality has been modified.

Changes

Cohort / File(s) Summary
Import path refactoring
controller/topup_creem.go
Updated import statements from local module aliases to external GitHub module path for common, model, and setting packages

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Imports dance from one home to another,
Local paths now point to distant cousins,
The code still hops just the same,
Only the address labels changed their name!
QuantumNous welcomes them with a bound! 🌟

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "fix(go): Correct Go module import paths" directly and clearly describes the main change in the changeset: updating import paths from the old "one-api/..." module aliases to the correct "github.com/QuantumNous/new-api/..." module path. The title is concise, uses clear and specific language, and follows conventional commit format with the "fix(go):" prefix to indicate this is a Go-related fix. A teammate reviewing the commit history would immediately understand that this PR addresses Go module import path corrections.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
controller/topup_creem.go (3)

40-42: Security risk: Signature verification bypassed in test mode.

In test mode, webhook signature verification is completely skipped. This allows any webhook request to be processed without authentication, potentially enabling unauthorized payment confirmations. Even in test environments, webhooks should be validated against a test secret to maintain security guarantees and catch integration issues.


102-102: Critical: Unchecked error could cause panic.

The error from GetUserById is ignored, and the user object is used without checking if it's nil. If the user lookup fails, accessing user.Id, user.Email, or user.Username on lines 105, 125 will cause a nil pointer dereference panic.

Apply this diff to handle the error:

-	user, _ := model.GetUserById(id, false)
+	user, err := model.GetUserById(id, false)
+	if err != nil || user == nil {
+		log.Printf("获取用户信息失败: %v", err)
+		c.JSON(200, gin.H{"message": "error", "data": "用户信息获取失败"})
+		return
+	}

423-423: Privacy concern: User email logged in plaintext.

User email (PII) is logged directly, while Line 319 redacts customer email. For GDPR/privacy compliance, mask or redact the email here as well.

Apply this diff:

-	log.Printf("发送Creem支付请求 - URL: %s, 产品ID: %s, 用户邮箱: %s, 订单号: %s",
-		apiUrl, product.ProductId, email, referenceId)
+	log.Printf("发送Creem支付请求 - URL: %s, 产品ID: %s, 用户邮箱: <redacted>, 订单号: %s",
+		apiUrl, product.ProductId, referenceId)
🧹 Nitpick comments (2)
controller/topup_creem.go (2)

156-156: Gate verbose logging behind test mode.

Logging the full request body may expose sensitive payment data in production logs. Consider restricting this to test mode only.

Apply this diff:

-	// 打印body内容
-	log.Printf("creem pay request body: %s", string(bodyBytes))
+	// 打印body内容(仅在测试模式)
+	if setting.CreemTestMode {
+		log.Printf("creem pay request body: %s", string(bodyBytes))
+	}

442-442: Gate API response logging behind test mode.

The full API response may contain sensitive information. Consider restricting this detailed logging to test mode only.

Apply this diff:

-	log.Printf("Creem API resp - status code: %d, resp: %s", resp.StatusCode, string(body))
+	if setting.CreemTestMode {
+		log.Printf("Creem API resp - status code: %d, resp: %s", resp.StatusCode, string(body))
+	} else {
+		log.Printf("Creem API resp - status code: %d", resp.StatusCode)
+	}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 36c603f and f60896a.

📒 Files selected for processing (1)
  • controller/topup_creem.go (1 hunks)
🔇 Additional comments (1)
controller/topup_creem.go (1)

13-15: LGTM! Import paths corrected.

The import paths have been properly updated to match the module path in go.mod, resolving the build errors.

@seefs001
seefs001 merged commit c3ed6a6 into QuantumNous:main Oct 28, 2025
1 check passed
@comeback01
comeback01 deleted the fix/go-import-paths branch December 11, 2025 12:43
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
jiutubaba pushed a commit to jiutubaba/fx-api that referenced this pull request May 17, 2026
…agination-localStorage

fix: 恢复表格分页大小 localStorage 持久化
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.

2 participants