@@ -338,12 +338,12 @@ func GenerateEnvScript(config *GPUEnvConfig, paths *platform.Paths) (string, err
338338
339339 // Export environment variables
340340 for k , v := range result .EnvVars {
341- script . WriteString ( fmt .Sprintf ( "export %s=\" %s\" \n " , k , v ) )
341+ fmt .Fprintf ( & script , "export %s=\" %s\" \n " , k , v )
342342 }
343343
344344 // Add LD_LIBRARY_PATH - use libs directory (only contains .so files)
345345 script .WriteString ("\n # Add GPU libraries to library path\n " )
346- script . WriteString ( fmt .Sprintf ( "export LD_LIBRARY_PATH=\" %s:$LD_LIBRARY_PATH\" \n " , libsPath ) )
346+ fmt .Fprintf ( & script , "export LD_LIBRARY_PATH=\" %s:$LD_LIBRARY_PATH\" \n " , libsPath )
347347
348348 // Add LD_PRELOAD based on vendor - use libs directory
349349 libNames := GetLibraryNames (config .Vendor )
@@ -353,12 +353,12 @@ func GenerateEnvScript(config *GPUEnvConfig, paths *platform.Paths) (string, err
353353 preloadPaths = append (preloadPaths , filepath .Join (libsPath , lib ))
354354 }
355355 script .WriteString ("\n # Preload GPU libraries\n " )
356- script . WriteString ( fmt .Sprintf ( "export LD_PRELOAD=\" %s${LD_PRELOAD:+:$LD_PRELOAD}\" \n " , strings .Join (preloadPaths , ":" ) ))
356+ fmt .Fprintf ( & script , "export LD_PRELOAD=\" %s${LD_PRELOAD:+:$LD_PRELOAD}\" \n " , strings .Join (preloadPaths , ":" ))
357357 }
358358
359359 script .WriteString ("\n # GPU Go environment activated\n " )
360- script . WriteString ( fmt .Sprintf ( "echo \" GPU Go environment activated for vendor: %s\" \n " , config .Vendor ) )
361- script . WriteString ( fmt .Sprintf ( "echo \" Connection URL: %s\" \n " , config .ConnectionURL ) )
360+ fmt .Fprintf ( & script , "echo \" GPU Go environment activated for vendor: %s\" \n " , config .Vendor )
361+ fmt .Fprintf ( & script , "echo \" Connection URL: %s\" \n " , config .ConnectionURL )
362362
363363 return script .String (), nil
364364}
@@ -388,34 +388,34 @@ func GeneratePowerShellScript(config *GPUEnvConfig, paths *platform.Paths) (stri
388388
389389 // Export environment variables
390390 for k , v := range result .EnvVars {
391- script . WriteString ( fmt .Sprintf ( "$env:%s = \" %s\" \n " , k , v ) )
391+ fmt .Fprintf ( & script , "$env:%s = \" %s\" \n " , k , v )
392392 }
393393
394394 // Set GPU vendor for ggo launch to detect correct DLLs
395- script . WriteString ( fmt .Sprintf ( "$env:TF_GPU_VENDOR = \" %s\" \n " , config .Vendor ) )
395+ fmt .Fprintf ( & script , "$env:TF_GPU_VENDOR = \" %s\" \n " , config .Vendor )
396396
397397 // Add libs path to PATH at the FRONT (best effort for DLL loading)
398398 // libs directory contains only .dll files
399399 script .WriteString ("\n # Add GPU libraries to PATH (prepend for priority)\n " )
400- script . WriteString ( fmt .Sprintf ( "$env:PATH = \" %s;$env:PATH\" \n " , libsPath ) )
400+ fmt .Fprintf ( & script , "$env:PATH = \" %s;$env:PATH\" \n " , libsPath )
401401
402402 // Set CUDA_PATH for applications that check it - point to libs directory
403403 script .WriteString ("\n # Set CUDA_PATH for CUDA-aware applications\n " )
404- script . WriteString ( fmt .Sprintf ( "$env:CUDA_PATH = \" %s\" \n " , libsPath ) )
405- script . WriteString ( fmt .Sprintf ( "$env:CUDA_HOME = \" %s\" \n " , libsPath ) )
404+ fmt .Fprintf ( & script , "$env:CUDA_PATH = \" %s\" \n " , libsPath )
405+ fmt .Fprintf ( & script , "$env:CUDA_HOME = \" %s\" \n " , libsPath )
406406
407407 // List required DLLs for this vendor
408408 windowsDLLs := GetWindowsLibraryNames (config .Vendor )
409409 if len (windowsDLLs ) > 0 {
410410 script .WriteString ("\n # Required DLLs for this vendor (should be in libs directory)\n " )
411411 for _ , dll := range windowsDLLs {
412- script . WriteString ( fmt .Sprintf ( "# - %s\n " , dll ) )
412+ fmt .Fprintf ( & script , "# - %s\n " , dll )
413413 }
414414 }
415415
416416 script .WriteString ("\n # GPU Go environment activated\n " )
417- script . WriteString ( fmt .Sprintf ( "Write-Host \" GPU Go environment activated for vendor: %s\" -ForegroundColor Green\n " , config .Vendor ) )
418- script . WriteString ( fmt .Sprintf ( "Write-Host \" Connection URL: %s\" \n " , config .ConnectionURL ) )
417+ fmt .Fprintf ( & script , "Write-Host \" GPU Go environment activated for vendor: %s\" -ForegroundColor Green\n " , config .Vendor )
418+ fmt .Fprintf ( & script , "Write-Host \" Connection URL: %s\" \n " , config .ConnectionURL )
419419 script .WriteString ("Write-Host \" \" \n " )
420420 script .WriteString ("Write-Host \" TIP: For reliable DLL loading, use 'ggo launch <program>'\" -ForegroundColor Yellow\n " )
421421 script .WriteString ("Write-Host \" Example: ggo launch python train.py\" \n " )
@@ -449,32 +449,32 @@ func GenerateBatchScript(config *GPUEnvConfig, paths *platform.Paths) (string, e
449449
450450 // Export environment variables
451451 for k , v := range result .EnvVars {
452- script . WriteString ( fmt .Sprintf ( "set %s=%s\n " , k , v ) )
452+ fmt .Fprintf ( & script , "set %s=%s\n " , k , v )
453453 }
454454
455455 // Set GPU vendor for ggo launch to detect correct DLLs
456- script . WriteString ( fmt .Sprintf ( "set TF_GPU_VENDOR=%s\n " , config .Vendor ) )
456+ fmt .Fprintf ( & script , "set TF_GPU_VENDOR=%s\n " , config .Vendor )
457457
458458 // Add libs path to PATH at the FRONT - libs directory contains only .dll files
459459 script .WriteString ("\n REM Add GPU libraries to PATH (prepend for priority)\n " )
460- script . WriteString ( fmt .Sprintf ( "set PATH=%s;%%PATH%%\n " , libsPath ) )
460+ fmt .Fprintf ( & script , "set PATH=%s;%%PATH%%\n " , libsPath )
461461
462462 // Set CUDA_PATH - point to libs directory
463463 script .WriteString ("\n REM Set CUDA_PATH for CUDA-aware applications\n " )
464- script . WriteString ( fmt .Sprintf ( "set CUDA_PATH=%s\n " , libsPath ) )
465- script . WriteString ( fmt .Sprintf ( "set CUDA_HOME=%s\n " , libsPath ) )
464+ fmt .Fprintf ( & script , "set CUDA_PATH=%s\n " , libsPath )
465+ fmt .Fprintf ( & script , "set CUDA_HOME=%s\n " , libsPath )
466466
467467 // List required DLLs for this vendor
468468 windowsDLLs := GetWindowsLibraryNames (config .Vendor )
469469 if len (windowsDLLs ) > 0 {
470470 script .WriteString ("\n REM Required DLLs for this vendor (should be in libs directory)\n " )
471471 for _ , dll := range windowsDLLs {
472- script . WriteString ( fmt .Sprintf ( "REM - %s\n " , dll ) )
472+ fmt .Fprintf ( & script , "REM - %s\n " , dll )
473473 }
474474 }
475475
476476 script .WriteString ("\n echo GPU Go environment activated!\n " )
477- script . WriteString ( fmt .Sprintf ( "echo Connection URL: %s\n " , config .ConnectionURL ) )
477+ fmt .Fprintf ( & script , "echo Connection URL: %s\n " , config .ConnectionURL )
478478 script .WriteString ("echo.\n " )
479479 script .WriteString ("echo TIP: For reliable DLL loading, use 'ggo launch ^<program^>'\n " )
480480 script .WriteString ("echo Example: ggo launch python train.py\n " )
0 commit comments