[PR #1468] [CLOSED] Use the xyproto/env package #36464

Closed
opened 2026-04-22 21:06:33 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/1468
Author: @xyproto
Created: 12/11/2023
Status: Closed

Base: mainHead: xyproto_env


📝 Commits (1)

  • bfb9675 Use the xyproto/env package

📊 Changes

6 files changed (+20 additions, -14 deletions)

View changed files

📝 cmd/cmd.go (+6 -4)
📝 go.mod (+1 -0)
📝 go.sum (+2 -0)
📝 server/images.go (+3 -2)
📝 server/modelpath.go (+5 -7)
📝 server/routes.go (+3 -1)

📄 Description

xyproto/env is a package that is used in production in at least company, and that is used in several open source projects and has a few (minor) advantages:

  • Cache the environment variables when the program is starting, for quick repeated lookups.
  • Use .Str() for strings, .Bool() for boolean values and .Dir() for directories, for clarity.

Also, changing:

if noprune := os.Getenv("OLLAMA_NOPRUNE"); noprune == "" {

into

if !env.Bool("OLLAMA_NOPRUNE") {

Is a change that highlights that the environment variable is being used like a boolean value, where it's either set or not.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/1468 **Author:** [@xyproto](https://github.com/xyproto) **Created:** 12/11/2023 **Status:** ❌ Closed **Base:** `main` ← **Head:** `xyproto_env` --- ### 📝 Commits (1) - [`bfb9675`](https://github.com/ollama/ollama/commit/bfb96753a15c61d091586ba92434638c409db3a6) Use the xyproto/env package ### 📊 Changes **6 files changed** (+20 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `cmd/cmd.go` (+6 -4) 📝 `go.mod` (+1 -0) 📝 `go.sum` (+2 -0) 📝 `server/images.go` (+3 -2) 📝 `server/modelpath.go` (+5 -7) 📝 `server/routes.go` (+3 -1) </details> ### 📄 Description xyproto/env is a package that is used in production in at least company, and that is used in several open source projects and has a few (minor) advantages: * Cache the environment variables when the program is starting, for quick repeated lookups. * Use `.Str()` for strings, `.Bool()` for boolean values and `.Dir()` for directories, for clarity. Also, changing: ```go if noprune := os.Getenv("OLLAMA_NOPRUNE"); noprune == "" { ``` into ```go if !env.Bool("OLLAMA_NOPRUNE") { ``` Is a change that highlights that the environment variable is being used like a boolean value, where it's either set or not. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-22 21:06:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#36464