fix: Updated the golang installer

This commit is contained in:
Mahmoud-Emad
2025-02-10 11:34:45 +00:00
parent f8cb6f25f7
commit 439dff4a64
3 changed files with 41 additions and 31 deletions

View File

@@ -2,14 +2,15 @@ module golang
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.installers.base
import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.installers.ulist
import os
// checks if a certain version or above is installed
fn installed_() !bool {
//////////////////// following actions are not specific to instance of the object
fn installed() !bool {
res := os.execute('/bin/bash -c "go version"')
if res.exit_code == 0 {
r := res.output.split_into_lines()
@@ -30,7 +31,16 @@ fn installed_() !bool {
return false
}
fn install_() ! {
// get the Upload List of the files
fn ulist_get() !ulist.UList {
// optionally build a UList which is all paths which are result of building, is then used e.g. in upload
return ulist.UList{}
}
// uploads to S3 server if configured
fn upload() ! {}
fn install() ! {
console.print_header('install golang')
base.install()!
// destroy()!
@@ -63,17 +73,9 @@ fn install_() ! {
osal.profile_path_add_remove(paths2add: '${go_dest}/bin')!
}
fn build_() ! {
}
fn build() ! {}
// get the Upload List of the files
fn ulist_get() !ulist.UList {
// mut installer := get()!
// optionally build a UList which is all paths which are result of building, is then used e.g. in upload
return ulist.UList{}
}
fn destroy_() ! {
fn destroy() ! {
console.print_debug('golang destroy')
osal.package_remove('golang')!

View File

@@ -1,12 +1,9 @@
module golang
import freeflowuniverse.herolib.core.base
import freeflowuniverse.herolib.core.playbook
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.data.paramsparser
import freeflowuniverse.herolib.sysadmin.startupmanager
import freeflowuniverse.herolib.osal.zinit
import time
__global (
golang_global map[string]&GolangInstaller
@@ -45,11 +42,11 @@ pub fn play(args_ PlayArgs) ! {
reset := p.get_default_false('reset')
if other_action.name == 'destroy' || reset {
console.print_debug('install action golang.destroy')
// destroy()!
destroy()!
}
if other_action.name == 'install' {
console.print_debug('install action golang.install')
// install()!
install()!
}
}
}
@@ -89,19 +86,19 @@ pub mut:
pub fn (mut self GolangInstaller) install(args InstallArgs) ! {
switch(self.name)
// if args.reset || (!installed()!) {
// install()!
// }
if args.reset || (!installed()!) {
install()!
}
}
pub fn (mut self GolangInstaller) build() ! {
switch(self.name)
// build()!
build()!
}
pub fn (mut self GolangInstaller) destroy() ! {
switch(self.name)
// destroy()!
destroy()!
}
// switch instance to be used for golang

View File

@@ -1,25 +1,36 @@
module golang
import freeflowuniverse.herolib.data.paramsparser
import os
import freeflowuniverse.herolib.data.encoderhero
pub const version = '1.23.1'
pub const version = '1.23.6'
const singleton = true
const default = true
// THIS THE THE SOURCE OF THE INFORMATION OF THIS FILE, HERE WE HAVE THE CONFIG OBJECT CONFIGURED AND MODELLED
@[heap]
pub struct GolangInstaller {
pub mut:
name string = 'default'
}
fn obj_init(obj_ GolangInstaller) !GolangInstaller {
// never call get here, only thing we can do here is work on object itself
mut obj := obj_
return obj
// your checking & initialization code if needed
fn obj_init(mycfg_ GolangInstaller) !GolangInstaller {
mut mycfg := mycfg_
return mycfg
}
// called before start if done
fn configure() ! {
// mut installer := get()!
}
/////////////NORMALLY NO NEED TO TOUCH
pub fn heroscript_dumps(obj GolangInstaller) !string {
return encoderhero.encode[GolangInstaller](obj)!
}
pub fn heroscript_loads(heroscript string) !GolangInstaller {
mut obj := encoderhero.decode[GolangInstaller](heroscript)!
return obj
}