Golang equivalent of creating a setup script

I am new to Go Lang World and currently converting a python code to golang

**Below is the python setup script **

import subprocess
import setup, Extension

class buildallC(Command):

def run(self):
print(“Running all C files”)
subprocess.call([‘gmake’, ‘-C’, ‘network-anomaly/Make/gcc’])
subprocess.call([‘gmake’, ‘-C’, ‘network-interface/Make/gcc’])

pynetwork = Extension(manifest.pynetwork, [ ‘pynetwork/pynetwork.cpp, pynetwork/checknetwork.cpp,],
libs=[‘gnutls’],
mydirs = [‘pynetwork’,’network-anomaly/include’,‘network interface/include’,’/usr/local/include’],
thecc=[‘network-anomaly/Make/gcc/lib/libnetwork-anomaly.a’,'network-interface/Make/gcc/lib/libnetwork-interface.a’]

setup(
name=‘SampleTest’,
version=‘2.0’,
packages=[‘SampleTest’],
ext_modules=[pynetwork],
class={
‘buildcprog’: buildallC,
}
)

Execution: python setup.py buildcprog

How to execute this portion in Go ?
subprocess.call([‘gmake’, ‘-C’, ‘network-anomaly/Make/gcc’])
subprocess.call([‘gmake’, ‘-C’, ‘network-interface/Make/gcc’])
pynetwork = Extension(manifest.pynetwork, [ ‘pynetwork/pynetwork.cpp, …

My answer to this question depends on the answer to a different one, first: What is it you’re trying to do? This Python code looks like it builds C Python modules. Are you really just trying to rewrite this setup script into Go to build C Python modules? If so, I’d ask, “why?” If you already have Python installed to use these Python modules, why not just keep using Python?

If you’re asking how to replace the C Python module(s) and/or Python code that uses the module(s), we’d need to see portions of the exact code that you’re trying to replace and we could give you suggestions.

Primarily, I am trying build and call the .c files under the folder network-anomaly , network-interface and pynetwork.

How to execute this portion in Go ?
subprocess.call([‘gmake’, ‘-C’, ‘network-anomaly/Make/gcc’])
subprocess.call([‘gmake’, ‘-C’, ‘network-interface/Make/gcc’])
pynetwork = Extension(manifest.pynetwork, [ ‘pynetwork/pynetwork.cpp, …

My yet to develop main Go code requires to call the libraries from the above folders rather than redeveloping them.

I used exec.Command(“gmake”,“C”," “network-anomaly/Make/gcc”) and seems to work fine

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.