stealer

package module
v0.0.0-...-c03e66a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2017 License: MIT Imports: 13 Imported by: 1

README

Stealer Build Status

Get all the variable name and the values from php, for example if you have some php code file mycode.php like :

    public function __construct(){
    
    }
    
    private function someFunctionHere(){
        return 1;
    }
    
    public function publicFunctionHere(){
        return 1;
    }
    
    private $persons = array('andy','clara','john');
    private static $persons_static = array("andys","claras","johns");
    public $animals = array("lion","wolf","tiger");
    public static $animals_static = array("lions","wolfs","tigers");
    protected $last_name= array('Abraham','Santana','Wijaya');
    private static $last_name_static = array('Abrahams','Santanas','Wijayas');

This library will convert all those variable and its values to Go :

package mypackage

var persons_static = []string{"andys", "claras", "johns"}

var last_name_static = []string{"Abrahams", "Santanas", "Wijayas"}

var last_name = []string{"Abraham", "Santana", "Wijaya"}

var animals = []string{"lion", "wolf", "tiger"}

var animals_static = []string{"lions", "wolfs", "tigers"}

var persons = []string{"andy", "clara", "john"}

Date type supported

Currently this library support for these data types :

  • stirng
  • int
  • float
  • bool

CLI

You can directly use this using CLI in the cmd/cli directory, here is the step installation for Ubuntu :

cd $GOPATH/src/github.com/Gujarats/stealer/cmd/cli/
go build
sudo mv cli /usr/local/bin/stealer
stealer

Usage from the source

Here is some snippet code to get started

package main

import (
	"log"

	"github.com/Gujarats/stealer"
)

func main() {
	err, steal := stealer.Steal("Person.php")
	if err != nil {
		log.Println(err)
	}

    // Save it to your path with the package name.
    // In this case the package name is main
	err = steal.Save("path/to/your/file/test.go", "main")
	if err != nil {
		log.Println(err)
	}
}

Documentation

Overview

All this function is used for CLI application. Plesae see this cmd/cli dir for the usage info Some of the function print the progress of converting file to Go Only in this place to print the progress not others

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(location, fileSavePath string)

convert all files in the given location

func ReadFile

func ReadFile(filepath string) (error, map[string][]string)

Read file and return its content.

func WriteFile

func WriteFile(pathFile, packageName string, data map[string][]string) error

Write all the variables and arrays into code to save them for the later usage

Types

type Stealer

type Stealer struct {
	Datas map[string][]string
}

func Steal

func Steal(path string) (error, *Stealer)

Steal some variable data from path phpfile

func (*Stealer) Save

func (s *Stealer) Save(savePath, packageName string) error

save all the variables and its values to new path TODO : write test case where the path is not exist and need to create the path first lets say path/to/specific/file.go need to create the folder first

Directories

Path Synopsis
cmd
cli command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL